From 312b7dc9710b615488ce78f1f7b47e766939fc36 Mon Sep 17 00:00:00 2001 From: Techatrix Date: Sat, 3 Aug 2024 02:09:44 +0200 Subject: [PATCH] remove usage of `usingnamespace` from StringPool --- src/analyser/string_pool.zig | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/analyser/string_pool.zig b/src/analyser/string_pool.zig index 9d7814394..62390de31 100644 --- a/src/analyser/string_pool.zig +++ b/src/analyser/string_pool.zig @@ -152,17 +152,13 @@ pub fn StringPool(comptime config: Config) type { return .{ .slice = pool.stringToSliceUnsafe(index) }; } - // usingnamespace is used here instead of doing a @compileError if - // `config.thread_safe` so that `std.testing.refAllDeclsRecursive` works. - usingnamespace if (config.thread_safe) struct {} else struct { - /// returns the underlying slice from an interned string - /// equal strings are guaranteed to share the same storage - /// - /// only callable when thread safety is disabled. - pub fn stringToSlice(pool: *Pool, index: String) [:0]const u8 { - return pool.stringToSliceUnsafe(index); - } - }; + /// returns the underlying slice from an interned string + /// equal strings are guaranteed to share the same storage + /// + /// only callable when thread safety is disabled. + pub const stringToSlice = if (config.thread_safe) @"usingnamespace" else stringToSliceUnsafe; + + const @"usingnamespace" = {}; /// returns the underlying slice from an interned string /// equal strings are guaranteed to share the same storage