Browse Source

[neko] Optimise BytesBuffer length field (#11090)

If the __get_length method is available, there is no need to allocate
a new string.
tobil4sk 2 năm trước cách đây
mục cha
commit
e3a9b91387
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  1. 2 0
      std/haxe/io/BytesBuffer.hx

+ 2 - 0
std/haxe/io/BytesBuffer.hx

@@ -63,6 +63,8 @@ class BytesBuffer {
 
 	inline function get_length():Int {
 		#if neko
+		if (@:privateAccess StringBuf.__get_length != null)
+			return untyped StringBuf.__get_length(b);
 		return untyped __dollar__ssize(StringBuf.__to_string(b));
 		#elseif cs
 		return haxe.Int64.toInt(b.Length);