mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
performance: use a comptime StaticStringMap for string comparison
This commit is contained in:
@@ -215,33 +215,31 @@ fn getMarkTime(self: *const Performance, mark_name: []const u8) !f64 {
|
||||
// `navigationStart` is an equivalent to 0.
|
||||
// Others are dependant to request arrival, end of request etc, but we
|
||||
// return a dummy 0 value for now.
|
||||
const navigation_timing_marks = [_][]const u8{
|
||||
"navigationStart",
|
||||
"unloadEventStart",
|
||||
"unloadEventEnd",
|
||||
"redirectStart",
|
||||
"redirectEnd",
|
||||
"fetchStart",
|
||||
"domainLookupStart",
|
||||
"domainLookupEnd",
|
||||
"connectStart",
|
||||
"connectEnd",
|
||||
"secureConnectionStart",
|
||||
"requestStart",
|
||||
"responseStart",
|
||||
"responseEnd",
|
||||
"domLoading",
|
||||
"domInteractive",
|
||||
"domContentLoadedEventStart",
|
||||
"domContentLoadedEventEnd",
|
||||
"domComplete",
|
||||
"loadEventStart",
|
||||
"loadEventEnd",
|
||||
};
|
||||
for (navigation_timing_marks) |name| {
|
||||
if (std.mem.eql(u8, name, mark_name)) {
|
||||
return 0;
|
||||
}
|
||||
const navigation_timing_marks = std.StaticStringMap(void).initComptime(.{
|
||||
.{ "navigationStart", {} },
|
||||
.{ "unloadEventStart", {} },
|
||||
.{ "unloadEventEnd", {} },
|
||||
.{ "redirectStart", {} },
|
||||
.{ "redirectEnd", {} },
|
||||
.{ "fetchStart", {} },
|
||||
.{ "domainLookupStart", {} },
|
||||
.{ "domainLookupEnd", {} },
|
||||
.{ "connectStart", {} },
|
||||
.{ "connectEnd", {} },
|
||||
.{ "secureConnectionStart", {} },
|
||||
.{ "requestStart", {} },
|
||||
.{ "responseStart", {} },
|
||||
.{ "responseEnd", {} },
|
||||
.{ "domLoading", {} },
|
||||
.{ "domInteractive", {} },
|
||||
.{ "domContentLoadedEventStart", {} },
|
||||
.{ "domContentLoadedEventEnd", {} },
|
||||
.{ "domComplete", {} },
|
||||
.{ "loadEventStart", {} },
|
||||
.{ "loadEventEnd", {} },
|
||||
});
|
||||
if (navigation_timing_marks.has(mark_name)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return error.SyntaxError; // Mark not found
|
||||
|
||||
Reference in New Issue
Block a user