diff options
| author | gingerBill <bill@gingerbill.org> | 2019-12-01 14:10:59 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-12-01 14:10:59 +0000 |
| commit | 9db81498d8fbf4b24383cd7de94619943ad4e01a (patch) | |
| tree | 6263d1649607f44a1d8affc2baf1d39da906698f /core/unicode | |
| parent | 7fbe0a6f2385e618ea4d3a724d2ed6147b6921bf (diff) | |
Make the `string` type elements "immutable", akin to `char const *` in C
Allows for extra security and optimization benefits
Diffstat (limited to 'core/unicode')
| -rw-r--r-- | core/unicode/utf8/utf8.odin | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/unicode/utf8/utf8.odin b/core/unicode/utf8/utf8.odin index bbf3994cd..6d0b32f48 100644 --- a/core/unicode/utf8/utf8.odin +++ b/core/unicode/utf8/utf8.odin @@ -90,7 +90,7 @@ encode_rune :: proc(c: rune) -> ([4]u8, int) { return buf, 4; } -decode_rune_in_string :: inline proc(s: string) -> (rune, int) do return decode_rune(cast([]u8)s); +decode_rune_in_string :: inline proc(s: string) -> (rune, int) do return decode_rune(transmute([]u8)s); decode_rune :: proc(s: []u8) -> (rune, int) { n := len(s); if n < 1 { @@ -130,7 +130,7 @@ decode_rune :: proc(s: []u8) -> (rune, int) { -decode_last_rune_in_string :: inline proc(s: string) -> (rune, int) do return decode_last_rune(cast([]u8)s); +decode_last_rune_in_string :: inline proc(s: string) -> (rune, int) do return decode_last_rune(transmute([]u8)s); decode_last_rune :: proc(s: []u8) -> (rune, int) { r: rune; size: int; @@ -260,7 +260,7 @@ valid_string :: proc(s: string) -> bool { rune_start :: inline proc(b: u8) -> bool do return b&0xc0 != 0x80; -rune_count_in_string :: inline proc(s: string) -> int do return rune_count(cast([]u8)s); +rune_count_in_string :: inline proc(s: string) -> int do return rune_count(transmute([]u8)s); rune_count :: proc(s: []u8) -> int { count := 0; n := len(s); |