mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-10-31 10:38:09 +08:00 
			
		
		
		
	Optimize performance. (#189)
Screen::ApplyShader accounted for 60% of the computation. This patch optimize it. Performance on a 80x80 frame improved from 1400 draw/s to 7000 draw/s.
This commit is contained in:
		| @@ -227,23 +227,30 @@ void Screen::ApplyShader() { | ||||
|   // Merge box characters togethers. | ||||
|   for (int y = 1; y < dimy_; ++y) { | ||||
|     for (int x = 1; x < dimx_; ++x) { | ||||
|       std::string& left = at(x - 1, y); | ||||
|       std::string& top = at(x, y - 1); | ||||
|       std::string& cur = at(x, y); | ||||
|       // Box drawing character uses exactly 3 byte. | ||||
|       std::string& cur = pixels_[y][x].character; | ||||
|       if (cur.size() != 3u) | ||||
|         continue; | ||||
|  | ||||
|       // Left vs current | ||||
|       // Left vs current. | ||||
|       std::string& left = pixels_[y][x-1].character; | ||||
|       if (left.size() == 3u) { | ||||
|         if (cur == "│" && left == "─") cur = "┤"; | ||||
|       if (cur == "─" && left == "│") left = "├"; | ||||
|         if (cur == "├" && left == "─") cur = "┼"; | ||||
|         if (cur == "─" && left == "│") left = "├"; | ||||
|         if (cur == "─" && left == "┤") left = "┼"; | ||||
|       } | ||||
|  | ||||
|       // Top vs current | ||||
|       // Top vs current. | ||||
|       std::string& top = pixels_[y-1][x].character; | ||||
|       if (top.size() == 3u) { | ||||
|         if (cur == "─" && top == "│") cur = "┴"; | ||||
|       if (cur == "│" && top == "─") top = "┬"; | ||||
|         if (cur == "┬" && top == "│") cur = "┼"; | ||||
|         if (cur == "│" && top == "─") top = "┬"; | ||||
|         if (cur == "│" && top == "┴") top = "┼"; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| // clang-format on | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Arthur Sonzogni
					Arthur Sonzogni