src: Improve speed of interpreter when working with Strings
[nit.git] / lib / core / text / native.nit
index 3eb41f2..051cefb 100644 (file)
@@ -84,6 +84,10 @@ extern class NativeString `{ char* `}
        # Copy `self` to `dest`.
        fun copy_to(dest: NativeString, length: Int, from: Int, to: Int) is intern
 
+       redef fun ==(o) is intern do return is_same_instance(o)
+
+       redef fun !=(o) is intern do return not is_same_instance(o)
+
        # Position of the first nul character.
        fun cstring_length: Int
        do
@@ -249,7 +253,7 @@ extern class NativeString `{ char* `}
        end
 
        # Number of UTF-8 characters in `self` starting at `from`, for a length of `bytelen`
-       fun utf8_length(from, bytelen: Int): Int do
+       fun utf8_length(from, bytelen: Int): Int is intern do
                var st = from
                var ln = 0
                while bytelen > 0 do