mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 12:44:43 +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.
|
// `navigationStart` is an equivalent to 0.
|
||||||
// Others are dependant to request arrival, end of request etc, but we
|
// Others are dependant to request arrival, end of request etc, but we
|
||||||
// return a dummy 0 value for now.
|
// return a dummy 0 value for now.
|
||||||
const navigation_timing_marks = [_][]const u8{
|
const navigation_timing_marks = std.StaticStringMap(void).initComptime(.{
|
||||||
"navigationStart",
|
.{ "navigationStart", {} },
|
||||||
"unloadEventStart",
|
.{ "unloadEventStart", {} },
|
||||||
"unloadEventEnd",
|
.{ "unloadEventEnd", {} },
|
||||||
"redirectStart",
|
.{ "redirectStart", {} },
|
||||||
"redirectEnd",
|
.{ "redirectEnd", {} },
|
||||||
"fetchStart",
|
.{ "fetchStart", {} },
|
||||||
"domainLookupStart",
|
.{ "domainLookupStart", {} },
|
||||||
"domainLookupEnd",
|
.{ "domainLookupEnd", {} },
|
||||||
"connectStart",
|
.{ "connectStart", {} },
|
||||||
"connectEnd",
|
.{ "connectEnd", {} },
|
||||||
"secureConnectionStart",
|
.{ "secureConnectionStart", {} },
|
||||||
"requestStart",
|
.{ "requestStart", {} },
|
||||||
"responseStart",
|
.{ "responseStart", {} },
|
||||||
"responseEnd",
|
.{ "responseEnd", {} },
|
||||||
"domLoading",
|
.{ "domLoading", {} },
|
||||||
"domInteractive",
|
.{ "domInteractive", {} },
|
||||||
"domContentLoadedEventStart",
|
.{ "domContentLoadedEventStart", {} },
|
||||||
"domContentLoadedEventEnd",
|
.{ "domContentLoadedEventEnd", {} },
|
||||||
"domComplete",
|
.{ "domComplete", {} },
|
||||||
"loadEventStart",
|
.{ "loadEventStart", {} },
|
||||||
"loadEventEnd",
|
.{ "loadEventEnd", {} },
|
||||||
};
|
});
|
||||||
for (navigation_timing_marks) |name| {
|
if (navigation_timing_marks.has(mark_name)) {
|
||||||
if (std.mem.eql(u8, name, mark_name)) {
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return error.SyntaxError; // Mark not found
|
return error.SyntaxError; // Mark not found
|
||||||
|
|||||||
Reference in New Issue
Block a user