sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit e4b98c49131adebf6b2e51f5ce72679e19842a0b
parent dc8daca0482e5cea235ca9e1ab40c558a1ea86ea
Author: Vickenty Fesunov <kent@setattr.net>
Date:   Wed, 24 Jun 2015 20:31:10 +0200

Make slice_by_display_length faster, part 1.

Return as soon as we have enough characters in the buffer.

Diffstat:
M lib/sup/util.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -253,7 +253,8 @@ class String
   def slice_by_display_length len
     each_char.each_with_object "" do |c, buffer|
       len -= c.display_length
-      buffer << c if len >= 0
+      return buffer if len < 0
+      buffer << c
     end
   end