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 years ago
parent
commit
e3a9b91387
1 changed files with 2 additions and 0 deletions
  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);