From ecf324e2138c7e950f283ed18b11954858c8c0a9 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 4 Dec 2020 18:50:30 +0000 Subject: [PATCH] Remove buffered type --- core/strings/strings.odin | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/core/strings/strings.odin b/core/strings/strings.odin index 07907bb45..7bb6c33fc 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -1012,19 +1012,14 @@ fields :: proc(s: string, allocator := context.allocator) -> []string #no_bounds // fields_proc makes no guarantee about the order in which it calls f(ch) // it assumes that `f` always returns the same value for a given ch fields_proc :: proc(s: string, f: proc(rune) -> bool, allocator := context.allocator) -> []string #no_bounds_check { - Span :: struct { - start: int, - end: int, - }; - - spans := make([dynamic]string, 0, 32, allocator); + substrings := make([dynamic]string, 0, 32, allocator); start := -1; for end, r in s { if f(r) { if start >= 0 { - append(&spans, s[start : end]); + append(&substrings, s[start : end]); // -1 could be used, but just speed it up through bitwise not // gotta love 2's complement start = ~start; @@ -1037,8 +1032,8 @@ fields_proc :: proc(s: string, f: proc(rune) -> bool, allocator := context.alloc } if start >= 0 { - append(&spans, s[start : end]); + append(&substrings, s[start : end]); } - return spans[:]; + return substrings[:]; }