Parcourir la source

get rid of couple of @:functionCode's

Dan Korostelev il y a 10 ans
Parent
commit
4316d337e0
2 fichiers modifiés avec 9 ajouts et 14 suppressions
  1. 1 0
      std/cs/_std/String.hx
  2. 8 14
      std/cs/internal/StringExt.hx

+ 1 - 0
std/cs/_std/String.hx

@@ -52,6 +52,7 @@ import cs.StdTypes;
 
 	static function fromCharCode( code : Int ) : String;
 
+	private function IndexOf(value:String, startIndex:Int, comparisonType:cs.system.StringComparison):Int;
 	private function Replace(oldValue:String, newValue:String):String;
 	private function StartsWith(value:String):Bool;
 	private function EndsWith(value:String):Bool;

+ 8 - 14
std/cs/internal/StringExt.hx

@@ -37,26 +37,20 @@ private typedef NativeString = String;
 		return null;
 	}
 
-	@:functionCode('
-			if ( ((uint) index) >= me.Length)
-				return default(haxe.lang.Null<int>);
-			else
-				return new haxe.lang.Null<int>((int)me[index], true);
-	')
 	public static function charCodeAt(me:NativeString, index:Int):Null<Int>
 	{
-		return null;
+		if (cast(index,UInt) >= me.length)
+			return null;
+		else
+			return cast me[index];
 	}
 
-	@:functionCode('
-			uint sIndex = (startIndex.hasValue) ? ((uint) startIndex.@value) : 0;
-			if (sIndex >= me.Length)
-				return -1;
-			return me.IndexOf(str, (int)sIndex, System.StringComparison.Ordinal);
-	')
 	public static function indexOf(me:NativeString, str:NativeString, ?startIndex:Int):Int
 	{
-		return -1;
+		var sIndex:Int = startIndex != null ? startIndex : 0;
+		if (sIndex >= me.length)
+			return -1;
+		return @:privateAccess me.IndexOf(str, sIndex, cs.system.StringComparison.Ordinal);
 	}
 
 	@:functionCode('