Skip to content

Commit

Permalink
remove usage of usingnamespace from StringPool
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Aug 3, 2024
1 parent d8fa63a commit 312b7dc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/analyser/string_pool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 312b7dc

Please sign in to comment.