Jelajahi Sumber

added fastGet

Nicolas Cannasse 13 tahun lalu
induk
melakukan
a62ee6785b
1 mengubah file dengan 20 tambahan dan 0 penghapusan
  1. 20 0
      std/haxe/io/Bytes.hx

+ 20 - 0
std/haxe/io/Bytes.hx

@@ -351,4 +351,24 @@ class Bytes {
 		#end
 	}
 
+	/**
+		Read the most efficiently possible the n-th byte of the data.
+		Behavior when reading outside of the available data is unspecified.
+	**/
+	public inline static function fastGet( b : BytesData, pos : Int ) : Int {
+		#if neko
+		return untyped __dollar__sget(b,pos);
+		#elseif flash9
+		return b[pos];
+		#elseif php
+		return untyped __call__("ord", b[pos]);
+		#elseif cpp
+		return untyped b[pos];
+		#elseif java
+		return b[pos] & 0xFF;
+		#else
+		return b[pos];
+		#end
+	}
+
 }