summaryrefslogtreecommitdiff
path: root/libtnsl/box/string.tnsl
diff options
context:
space:
mode:
Diffstat (limited to 'libtnsl/box/string.tnsl')
-rw-r--r--libtnsl/box/string.tnsl25
1 files changed, 16 insertions, 9 deletions
diff --git a/libtnsl/box/string.tnsl b/libtnsl/box/string.tnsl
index d661676..675db06 100644
--- a/libtnsl/box/string.tnsl
+++ b/libtnsl/box/string.tnsl
@@ -30,19 +30,26 @@
}
/; method String
- /; cmp (String str) [int]
- /; loop (self.)
+ # Returns index of first difference, or -1 if there is no difference
+ /; diff_index (String str) [int]
+ ;uint l = math.mint(uint, str.length, self.length)
+ /; loop (uint i = 0; i < l) [i++]
+ /; if (self{i} != str{i})
+ ;return i [int]
+ ;/
+ ;/
+
+ /; if ()
;/
+
+ ;return -1
;/
/; override operator == (String str) [bool]
- ;return cmp(str) == 0
+ /; if (self.encoding != str.encoding || self.length != str.length)
+ ;return false
+ ;/
+ ;return diff_index(str) == -1
;/
;/
-
-;struct WString extends Vector (uint16) {}
-
-/; method WString
-
-;/ \ No newline at end of file