Browse Source

optimize StringBuf.add(string)

Nicolas Cannasse 5 years ago
parent
commit
565a191b47
1 changed files with 5 additions and 0 deletions
  1. 5 0
      std/hl/_std/StringBuf.hx

+ 5 - 0
std/hl/_std/StringBuf.hx

@@ -55,6 +55,11 @@
 
 	public function add<T>(x:T):Void {
 		var slen = 0;
+		var str = Std.downcast((x:Dynamic),String);
+		if( str != null ) {
+			__add(@:privateAccess str.bytes, 0, str.length<<1);
+			return;
+		}
 		var sbytes = hl.Bytes.fromValue(x, new hl.Ref(slen));
 		__add(sbytes, 0, slen << 1);
 	}