commit dfcad55c174ac57fb518038b705baf0ac7cb1b22
parent 3186faa225d926d17b369afc7e648d94ed8c2d77
Author: Drew DeVault <sir@cmpwn.com>
Date: Sat, 27 Feb 2021 10:31:52 -0500
strings: drop @init function for c_empty
We can directly reference the buffer now, after some harec improvements.
Diffstat:
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/strings/cstrings.ha b/strings/cstrings.ha
@@ -1,14 +1,11 @@
use encoding::utf8;
use types;
+let emptybuf: [1]u8 = [0];
+
// A C-compatible empty string. Empty Hare strings have a null pointer instead
// of containing only '\0', so a special string is needed for this case.
-export let c_empty: *const char = null: *const char;
-
-@init fn init() void = {
- static let buf: [1]u8 = [0];
- c_empty = &buf: *[*]u8: *const char;
-};
+export let c_empty: *const char = &emptybuf: *[*]u8: *const char;
// Computes the length of a NUL-terminated C string, in octets, in O(n). The
// computed length does not include the NUL terminator.