aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-22 18:12:18 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-22 18:12:18 -0700
commit1a284a1c94f0468634e35246f58a8381a2085616 (patch)
treec083b1a7ea1bfe0ad6b36c57fe636fecd93a0e24
parentf12dd51c006b3df0f99fda77800c7778225fccff (diff)
downloadbun-1a284a1c94f0468634e35246f58a8381a2085616.tar.gz
bun-1a284a1c94f0468634e35246f58a8381a2085616.tar.zst
bun-1a284a1c94f0468634e35246f58a8381a2085616.zip
Extremely minor perf improvements
-rw-r--r--src/http.zig6
-rw-r--r--src/linker.zig7
2 files changed, 7 insertions, 6 deletions
diff --git a/src/http.zig b/src/http.zig
index 29f58b186..2a653ad61 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -2252,13 +2252,13 @@ pub const RequestContext = struct {
const extname = ctx.url.extname;
switch (extname.len) {
3 => {
- if (!(strings.eqlComptime(extname, "css") or strings.eqlComptime(extname, "tsx") or strings.eqlComptime(extname, "jsx") or strings.eqlComptime(extname, "mjs"))) return try ctx.sendNotFound();
+ if (!(strings.eqlComptimeIgnoreLen(extname, "css") or strings.eqlComptimeIgnoreLen(extname, "tsx") or strings.eqlComptimeIgnoreLen(extname, "jsx") or strings.eqlComptime(extname, "mjs"))) return try ctx.sendNotFound();
},
2 => {
- if (!(strings.eqlComptime(extname, "js") or strings.eqlComptime(extname, "ts"))) return try ctx.sendNotFound();
+ if (!(strings.eqlComptimeIgnoreLen(extname, "js") or strings.eqlComptimeIgnoreLen(extname, "ts"))) return try ctx.sendNotFound();
},
4 => {
- if (!(strings.eqlComptime(extname, "json") or strings.eqlComptime(extname, "yaml"))) return try ctx.sendNotFound();
+ if (!(strings.eqlComptimeIgnoreLen(extname, "json") or strings.eqlComptimeIgnoreLen(extname, "yaml"))) return try ctx.sendNotFound();
},
else => {
return try ctx.sendNotFound();
diff --git a/src/linker.zig b/src/linker.zig
index 8e0a8cb43..8032db6dd 100644
--- a/src/linker.zig
+++ b/src/linker.zig
@@ -264,9 +264,10 @@ pub fn NewLinker(comptime BundlerType: type) type {
const node_module_root = std.fs.path.sep_str ++ "node_modules" ++ std.fs.path.sep_str;
if (strings.lastIndexOf(package_base_dir, node_module_root)) |last_node_modules| {
if (node_modules_bundle.getPackageIDByName(package_json.name)) |possible_pkg_ids| {
+ const packages = node_modules_bundle.bundle.packages;
const pkg_id: u32 = brk: {
for (possible_pkg_ids) |pkg_id| {
- const pkg = node_modules_bundle.bundle.packages[pkg_id];
+ const pkg = packages[pkg_id];
if (pkg.hash == package_json.hash) {
break :brk pkg_id;
}
@@ -280,7 +281,7 @@ pub fn NewLinker(comptime BundlerType: type) type {
.{
package_json.name,
package_json.name,
- node_modules_bundle.str(node_modules_bundle.bundle.packages[possible_pkg_ids[0]].version),
+ node_modules_bundle.str(packages[possible_pkg_ids[0]].version),
package_json.name,
package_json.version,
},
@@ -288,7 +289,7 @@ pub fn NewLinker(comptime BundlerType: type) type {
break :bundled;
};
- const package = &node_modules_bundle.bundle.packages[pkg_id];
+ const package = &packages[pkg_id];
if (comptime isDebug) {
std.debug.assert(strings.eql(node_modules_bundle.str(package.name), package_json.name));