aboutsummaryrefslogtreecommitdiff
path: root/src/comptime_string_map.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-06-11 05:26:37 -0700
committerGravatar GitHub <noreply@github.com> 2023-06-11 05:26:37 -0700
commitef65f3c305e989bd7d7fe6f0e73822bdbe0e91dd (patch)
tree208a5f55d885c95afe40366bbe7b0e6d4c5f7859 /src/comptime_string_map.zig
parent02eafd5019150357012ebb7a39f1c264ba73599e (diff)
downloadbun-ef65f3c305e989bd7d7fe6f0e73822bdbe0e91dd.tar.gz
bun-ef65f3c305e989bd7d7fe6f0e73822bdbe0e91dd.tar.zst
bun-ef65f3c305e989bd7d7fe6f0e73822bdbe0e91dd.zip
Support using `WTF::StringImpl` from Zig (#3279)
* Fix `make headers` * [JS parser] Fix bug with printing non-ascii import paths in ascii mode * Introduce `bun.String` * Add test for non-ascii imports & entry points * Add comment * Fix build issue * Support HTTP server * Make it print the same --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/comptime_string_map.zig')
-rw-r--r--src/comptime_string_map.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/comptime_string_map.zig b/src/comptime_string_map.zig
index 1963fc8de..01b5de5b0 100644
--- a/src/comptime_string_map.zig
+++ b/src/comptime_string_map.zig
@@ -146,12 +146,14 @@ pub fn ComptimeStringMapWithKeyType(comptime KeyType: type, comptime V: type, co
}
pub fn getWithEql(input: anytype, comptime eql: anytype) ?V {
- if (input.len < precomputed.min_len or input.len > precomputed.max_len)
+ const Input = @TypeOf(input);
+ const length = if (comptime std.meta.trait.isSlice(Input) or std.meta.trait.isZigString(Input)) input.len else input.length();
+ if (length < precomputed.min_len or length > precomputed.max_len)
return null;
comptime var i: usize = precomputed.min_len;
inline while (i <= precomputed.max_len) : (i += 1) {
- if (input.len == i) {
+ if (length == i) {
return getWithLengthAndEql(input, i, eql);
}
}