From 9e83bf8c3656b736ba3a14d9b7b8af61b48415f4 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Thu, 30 Apr 2020 11:54:19 -0700 Subject: chore: move from new to make prefix of constructors --- sys/libn/string.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sys/libn/string.c') diff --git a/sys/libn/string.c b/sys/libn/string.c index d5bb7ef..4280e27 100644 --- a/sys/libn/string.c +++ b/sys/libn/string.c @@ -156,7 +156,7 @@ utf8·findrune(byte* s, long c) // len defines the length of the C substring that we will copy into our buffer. // The backing buffer will have capacity cap. string -str·newcap(const byte* s, vlong len, vlong cap) +str·makecap(const byte* s, vlong len, vlong cap) { struct str·Hdr* h; @@ -185,34 +185,34 @@ cleanup: // New returns a new dynamic string object, initialized from the given C string. // The backing buffer capacity is equivalent to the string length. string -str·newlen(const byte* s, vlong len) +str·makelen(const byte* s, vlong len) { vlong sl = (!s) ? 0 : strlen(s); if (sl < len) panicf("attempted to take a bigger substring than string length"); vlong cap = (len == 0) ? 1 : len; - return str·newcap(s, len, cap); + return str·makecap(s, len, cap); } // New returns a new dynamic string object, initialized from the given C string. // The backing buffer capacity is equivalent to the string length. string -str·new(const byte* s) +str·make(const byte* s) { vlong len = (!s) ? 0 : strlen(s); - return str·newlen(s, len); + return str·makelen(s, len); } // Newf returns a new dynamic string object string -str·newf(const byte* fmt, ...) +str·makef(const byte* fmt, ...) { va_list args; va_start(args, fmt); vlong n = vsnprintf(nil, 0, fmt, args); va_end(args); - string s = str·newcap(nil, 0, n); + string s = str·makecap(nil, 0, n); va_start(args, fmt); vsnprintf(s, n + 1, fmt, args); @@ -473,7 +473,7 @@ str·split(string s, const byte* tok) for (vlong i = 0; i < sL - tokL; i++) { if ((tokL == 1 && s[i] == tokL) || !memcmp(s + i, tok, tokL)) { - bufpush(fields, str·newlen(s + start, i - start)); + bufpush(fields, str·makelen(s + start, i - start)); if (fields[buflen(fields) - 1] == nil) goto cleanup; start = i + tokL; @@ -481,7 +481,7 @@ str·split(string s, const byte* tok) } } - bufpush(fields, str·newlen(s + start, sL - start)); + bufpush(fields, str·makelen(s + start, sL - start)); return fields; @@ -496,7 +496,7 @@ cleanup: string str·join(vlong len, byte** fields, const byte* sep) { - string s = str·newcap(nil, 0, 10); + string s = str·makecap(nil, 0, 10); int j = 0; for (j = 0; j < len; j++) { -- cgit v1.2.1