mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
10% perf improvement to JSX entity code parsing in microbenchmark
This commit is contained in:
@@ -1835,7 +1835,6 @@ fn NewLexer_(
|
||||
}
|
||||
|
||||
pub fn init(log: *logger.Log, source: logger.Source, allocator: std.mem.Allocator) !LexerType {
|
||||
try tables.initJSXEntityMap();
|
||||
var empty_string_literal: JavascriptString = &emptyJavaScriptString;
|
||||
var lex = LexerType{
|
||||
.log = log,
|
||||
@@ -2308,7 +2307,7 @@ fn NewLexer_(
|
||||
return decoded.items;
|
||||
}
|
||||
|
||||
inline fn maybeDecodeJSXEntity(lexer: *LexerType, text: string, cursor: *strings.CodepointIterator.Cursor) void {
|
||||
fn maybeDecodeJSXEntity(lexer: *LexerType, text: string, cursor: *strings.CodepointIterator.Cursor) void {
|
||||
lexer.assertNotJSON();
|
||||
|
||||
if (strings.indexOfChar(text[cursor.width + cursor.i ..], ';')) |length| {
|
||||
|
||||
@@ -192,16 +192,16 @@ pub const Keywords = ComptimeStringMap(T, .{
|
||||
.{ "with", .t_with },
|
||||
});
|
||||
|
||||
pub const StrictModeReservedWords = ComptimeStringMap(bool, .{
|
||||
.{ "implements", true },
|
||||
.{ "interface", true },
|
||||
.{ "let", true },
|
||||
.{ "package", true },
|
||||
.{ "private", true },
|
||||
.{ "protected", true },
|
||||
.{ "public", true },
|
||||
.{ "static", true },
|
||||
.{ "yield", true },
|
||||
pub const StrictModeReservedWords = ComptimeStringMap(void, .{
|
||||
.{ "implements", void{} },
|
||||
.{ "interface", void{} },
|
||||
.{ "let", void{} },
|
||||
.{ "package", void{} },
|
||||
.{ "private", void{} },
|
||||
.{ "protected", void{} },
|
||||
.{ "public", void{} },
|
||||
.{ "static", void{} },
|
||||
.{ "yield", void{} },
|
||||
});
|
||||
|
||||
pub const StrictModeReservedWordsRemap = ComptimeStringMap(string, .{
|
||||
@@ -245,9 +245,9 @@ pub const PropertyModifierKeyword = enum {
|
||||
};
|
||||
|
||||
pub const TypeScriptAccessibilityModifier = ComptimeStringMap(u1, .{
|
||||
.{ "public", 1 },
|
||||
.{ "private", 1 },
|
||||
.{ "protected", 1 },
|
||||
.{ "public", 1 },
|
||||
.{ "readonly", 1 },
|
||||
});
|
||||
|
||||
@@ -544,8 +544,6 @@ pub const TypescriptStmtKeyword = enum {
|
||||
});
|
||||
};
|
||||
|
||||
pub const JSXEntityMap = std.StringHashMap(CodePoint);
|
||||
|
||||
// Error: meta is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.
|
||||
pub const ChildlessJSXTags = ComptimeStringMap(void, .{
|
||||
.{ "area", void },
|
||||
@@ -558,282 +556,270 @@ pub const ChildlessJSXTags = ComptimeStringMap(void, .{
|
||||
.{ "input", void },
|
||||
.{ "keygen", void },
|
||||
.{ "link", void },
|
||||
.{ "menuitem", void },
|
||||
.{ "meta", void },
|
||||
.{ "param", void },
|
||||
.{ "source", void },
|
||||
.{ "track", void },
|
||||
.{ "wbr", void },
|
||||
.{ "menuitem", void },
|
||||
});
|
||||
|
||||
pub var jsxEntity: JSXEntityMap = undefined;
|
||||
var has_loaded_jsx_map = false;
|
||||
|
||||
// There's probably a way to move this to comptime
|
||||
pub fn initJSXEntityMap() !void {
|
||||
if (has_loaded_jsx_map) {
|
||||
return;
|
||||
}
|
||||
|
||||
has_loaded_jsx_map = true;
|
||||
jsxEntity = JSXEntityMap.init(default_allocator);
|
||||
// return jsxEntity;
|
||||
jsxEntity.ensureTotalCapacity(255) catch unreachable;
|
||||
|
||||
jsxEntity.putAssumeCapacity("quot", @as(CodePoint, 0x0022));
|
||||
jsxEntity.putAssumeCapacity("amp", @as(CodePoint, 0x0026));
|
||||
jsxEntity.putAssumeCapacity("apos", @as(CodePoint, 0x0027));
|
||||
jsxEntity.putAssumeCapacity("lt", @as(CodePoint, 0x003C));
|
||||
jsxEntity.putAssumeCapacity("gt", @as(CodePoint, 0x003E));
|
||||
jsxEntity.putAssumeCapacity("nbsp", @as(CodePoint, 0x00A0));
|
||||
jsxEntity.putAssumeCapacity("iexcl", @as(CodePoint, 0x00A1));
|
||||
jsxEntity.putAssumeCapacity("cent", @as(CodePoint, 0x00A2));
|
||||
jsxEntity.putAssumeCapacity("pound", @as(CodePoint, 0x00A3));
|
||||
jsxEntity.putAssumeCapacity("curren", @as(CodePoint, 0x00A4));
|
||||
jsxEntity.putAssumeCapacity("yen", @as(CodePoint, 0x00A5));
|
||||
jsxEntity.putAssumeCapacity("brvbar", @as(CodePoint, 0x00A6));
|
||||
jsxEntity.putAssumeCapacity("sect", @as(CodePoint, 0x00A7));
|
||||
jsxEntity.putAssumeCapacity("uml", @as(CodePoint, 0x00A8));
|
||||
jsxEntity.putAssumeCapacity("copy", @as(CodePoint, 0x00A9));
|
||||
jsxEntity.putAssumeCapacity("ordf", @as(CodePoint, 0x00AA));
|
||||
jsxEntity.putAssumeCapacity("laquo", @as(CodePoint, 0x00AB));
|
||||
jsxEntity.putAssumeCapacity("not", @as(CodePoint, 0x00AC));
|
||||
jsxEntity.putAssumeCapacity("shy", @as(CodePoint, 0x00AD));
|
||||
jsxEntity.putAssumeCapacity("reg", @as(CodePoint, 0x00AE));
|
||||
jsxEntity.putAssumeCapacity("macr", @as(CodePoint, 0x00AF));
|
||||
jsxEntity.putAssumeCapacity("deg", @as(CodePoint, 0x00B0));
|
||||
jsxEntity.putAssumeCapacity("plusmn", @as(CodePoint, 0x00B1));
|
||||
jsxEntity.putAssumeCapacity("sup2", @as(CodePoint, 0x00B2));
|
||||
jsxEntity.putAssumeCapacity("sup3", @as(CodePoint, 0x00B3));
|
||||
jsxEntity.putAssumeCapacity("acute", @as(CodePoint, 0x00B4));
|
||||
jsxEntity.putAssumeCapacity("micro", @as(CodePoint, 0x00B5));
|
||||
jsxEntity.putAssumeCapacity("para", @as(CodePoint, 0x00B6));
|
||||
jsxEntity.putAssumeCapacity("middot", @as(CodePoint, 0x00B7));
|
||||
jsxEntity.putAssumeCapacity("cedil", @as(CodePoint, 0x00B8));
|
||||
jsxEntity.putAssumeCapacity("sup1", @as(CodePoint, 0x00B9));
|
||||
jsxEntity.putAssumeCapacity("ordm", @as(CodePoint, 0x00BA));
|
||||
jsxEntity.putAssumeCapacity("raquo", @as(CodePoint, 0x00BB));
|
||||
jsxEntity.putAssumeCapacity("frac14", @as(CodePoint, 0x00BC));
|
||||
jsxEntity.putAssumeCapacity("frac12", @as(CodePoint, 0x00BD));
|
||||
jsxEntity.putAssumeCapacity("frac34", @as(CodePoint, 0x00BE));
|
||||
jsxEntity.putAssumeCapacity("iquest", @as(CodePoint, 0x00BF));
|
||||
jsxEntity.putAssumeCapacity("Agrave", @as(CodePoint, 0x00C0));
|
||||
jsxEntity.putAssumeCapacity("Aacute", @as(CodePoint, 0x00C1));
|
||||
jsxEntity.putAssumeCapacity("Acirc", @as(CodePoint, 0x00C2));
|
||||
jsxEntity.putAssumeCapacity("Atilde", @as(CodePoint, 0x00C3));
|
||||
jsxEntity.putAssumeCapacity("Auml", @as(CodePoint, 0x00C4));
|
||||
jsxEntity.putAssumeCapacity("Aring", @as(CodePoint, 0x00C5));
|
||||
jsxEntity.putAssumeCapacity("AElig", @as(CodePoint, 0x00C6));
|
||||
jsxEntity.putAssumeCapacity("Ccedil", @as(CodePoint, 0x00C7));
|
||||
jsxEntity.putAssumeCapacity("Egrave", @as(CodePoint, 0x00C8));
|
||||
jsxEntity.putAssumeCapacity("Eacute", @as(CodePoint, 0x00C9));
|
||||
jsxEntity.putAssumeCapacity("Ecirc", @as(CodePoint, 0x00CA));
|
||||
jsxEntity.putAssumeCapacity("Euml", @as(CodePoint, 0x00CB));
|
||||
jsxEntity.putAssumeCapacity("Igrave", @as(CodePoint, 0x00CC));
|
||||
jsxEntity.putAssumeCapacity("Iacute", @as(CodePoint, 0x00CD));
|
||||
jsxEntity.putAssumeCapacity("Icirc", @as(CodePoint, 0x00CE));
|
||||
jsxEntity.putAssumeCapacity("Iuml", @as(CodePoint, 0x00CF));
|
||||
jsxEntity.putAssumeCapacity("ETH", @as(CodePoint, 0x00D0));
|
||||
jsxEntity.putAssumeCapacity("Ntilde", @as(CodePoint, 0x00D1));
|
||||
jsxEntity.putAssumeCapacity("Ograve", @as(CodePoint, 0x00D2));
|
||||
jsxEntity.putAssumeCapacity("Oacute", @as(CodePoint, 0x00D3));
|
||||
jsxEntity.putAssumeCapacity("Ocirc", @as(CodePoint, 0x00D4));
|
||||
jsxEntity.putAssumeCapacity("Otilde", @as(CodePoint, 0x00D5));
|
||||
jsxEntity.putAssumeCapacity("Ouml", @as(CodePoint, 0x00D6));
|
||||
jsxEntity.putAssumeCapacity("times", @as(CodePoint, 0x00D7));
|
||||
jsxEntity.putAssumeCapacity("Oslash", @as(CodePoint, 0x00D8));
|
||||
jsxEntity.putAssumeCapacity("Ugrave", @as(CodePoint, 0x00D9));
|
||||
jsxEntity.putAssumeCapacity("Uacute", @as(CodePoint, 0x00DA));
|
||||
jsxEntity.putAssumeCapacity("Ucirc", @as(CodePoint, 0x00DB));
|
||||
jsxEntity.putAssumeCapacity("Uuml", @as(CodePoint, 0x00DC));
|
||||
jsxEntity.putAssumeCapacity("Yacute", @as(CodePoint, 0x00DD));
|
||||
jsxEntity.putAssumeCapacity("THORN", @as(CodePoint, 0x00DE));
|
||||
jsxEntity.putAssumeCapacity("szlig", @as(CodePoint, 0x00DF));
|
||||
jsxEntity.putAssumeCapacity("agrave", @as(CodePoint, 0x00E0));
|
||||
jsxEntity.putAssumeCapacity("aacute", @as(CodePoint, 0x00E1));
|
||||
jsxEntity.putAssumeCapacity("acirc", @as(CodePoint, 0x00E2));
|
||||
jsxEntity.putAssumeCapacity("atilde", @as(CodePoint, 0x00E3));
|
||||
jsxEntity.putAssumeCapacity("auml", @as(CodePoint, 0x00E4));
|
||||
jsxEntity.putAssumeCapacity("aring", @as(CodePoint, 0x00E5));
|
||||
jsxEntity.putAssumeCapacity("aelig", @as(CodePoint, 0x00E6));
|
||||
jsxEntity.putAssumeCapacity("ccedil", @as(CodePoint, 0x00E7));
|
||||
jsxEntity.putAssumeCapacity("egrave", @as(CodePoint, 0x00E8));
|
||||
jsxEntity.putAssumeCapacity("eacute", @as(CodePoint, 0x00E9));
|
||||
jsxEntity.putAssumeCapacity("ecirc", @as(CodePoint, 0x00EA));
|
||||
jsxEntity.putAssumeCapacity("euml", @as(CodePoint, 0x00EB));
|
||||
jsxEntity.putAssumeCapacity("igrave", @as(CodePoint, 0x00EC));
|
||||
jsxEntity.putAssumeCapacity("iacute", @as(CodePoint, 0x00ED));
|
||||
jsxEntity.putAssumeCapacity("icirc", @as(CodePoint, 0x00EE));
|
||||
jsxEntity.putAssumeCapacity("iuml", @as(CodePoint, 0x00EF));
|
||||
jsxEntity.putAssumeCapacity("eth", @as(CodePoint, 0x00F0));
|
||||
jsxEntity.putAssumeCapacity("ntilde", @as(CodePoint, 0x00F1));
|
||||
jsxEntity.putAssumeCapacity("ograve", @as(CodePoint, 0x00F2));
|
||||
jsxEntity.putAssumeCapacity("oacute", @as(CodePoint, 0x00F3));
|
||||
jsxEntity.putAssumeCapacity("ocirc", @as(CodePoint, 0x00F4));
|
||||
jsxEntity.putAssumeCapacity("otilde", @as(CodePoint, 0x00F5));
|
||||
jsxEntity.putAssumeCapacity("ouml", @as(CodePoint, 0x00F6));
|
||||
jsxEntity.putAssumeCapacity("divide", @as(CodePoint, 0x00F7));
|
||||
jsxEntity.putAssumeCapacity("oslash", @as(CodePoint, 0x00F8));
|
||||
jsxEntity.putAssumeCapacity("ugrave", @as(CodePoint, 0x00F9));
|
||||
jsxEntity.putAssumeCapacity("uacute", @as(CodePoint, 0x00FA));
|
||||
jsxEntity.putAssumeCapacity("ucirc", @as(CodePoint, 0x00FB));
|
||||
jsxEntity.putAssumeCapacity("uuml", @as(CodePoint, 0x00FC));
|
||||
jsxEntity.putAssumeCapacity("yacute", @as(CodePoint, 0x00FD));
|
||||
jsxEntity.putAssumeCapacity("thorn", @as(CodePoint, 0x00FE));
|
||||
jsxEntity.putAssumeCapacity("yuml", @as(CodePoint, 0x00FF));
|
||||
jsxEntity.putAssumeCapacity("OElig", @as(CodePoint, 0x0152));
|
||||
jsxEntity.putAssumeCapacity("oelig", @as(CodePoint, 0x0153));
|
||||
jsxEntity.putAssumeCapacity("Scaron", @as(CodePoint, 0x0160));
|
||||
jsxEntity.putAssumeCapacity("scaron", @as(CodePoint, 0x0161));
|
||||
jsxEntity.putAssumeCapacity("Yuml", @as(CodePoint, 0x0178));
|
||||
jsxEntity.putAssumeCapacity("fnof", @as(CodePoint, 0x0192));
|
||||
jsxEntity.putAssumeCapacity("circ", @as(CodePoint, 0x02C6));
|
||||
jsxEntity.putAssumeCapacity("tilde", @as(CodePoint, 0x02DC));
|
||||
jsxEntity.putAssumeCapacity("Alpha", @as(CodePoint, 0x0391));
|
||||
jsxEntity.putAssumeCapacity("Beta", @as(CodePoint, 0x0392));
|
||||
jsxEntity.putAssumeCapacity("Gamma", @as(CodePoint, 0x0393));
|
||||
jsxEntity.putAssumeCapacity("Delta", @as(CodePoint, 0x0394));
|
||||
jsxEntity.putAssumeCapacity("Epsilon", @as(CodePoint, 0x0395));
|
||||
jsxEntity.putAssumeCapacity("Zeta", @as(CodePoint, 0x0396));
|
||||
jsxEntity.putAssumeCapacity("Eta", @as(CodePoint, 0x0397));
|
||||
jsxEntity.putAssumeCapacity("Theta", @as(CodePoint, 0x0398));
|
||||
jsxEntity.putAssumeCapacity("Iota", @as(CodePoint, 0x0399));
|
||||
jsxEntity.putAssumeCapacity("Kappa", @as(CodePoint, 0x039A));
|
||||
jsxEntity.putAssumeCapacity("Lambda", @as(CodePoint, 0x039B));
|
||||
jsxEntity.putAssumeCapacity("Mu", @as(CodePoint, 0x039C));
|
||||
jsxEntity.putAssumeCapacity("Nu", @as(CodePoint, 0x039D));
|
||||
jsxEntity.putAssumeCapacity("Xi", @as(CodePoint, 0x039E));
|
||||
jsxEntity.putAssumeCapacity("Omicron", @as(CodePoint, 0x039F));
|
||||
jsxEntity.putAssumeCapacity("Pi", @as(CodePoint, 0x03A0));
|
||||
jsxEntity.putAssumeCapacity("Rho", @as(CodePoint, 0x03A1));
|
||||
jsxEntity.putAssumeCapacity("Sigma", @as(CodePoint, 0x03A3));
|
||||
jsxEntity.putAssumeCapacity("Tau", @as(CodePoint, 0x03A4));
|
||||
jsxEntity.putAssumeCapacity("Upsilon", @as(CodePoint, 0x03A5));
|
||||
jsxEntity.putAssumeCapacity("Phi", @as(CodePoint, 0x03A6));
|
||||
jsxEntity.putAssumeCapacity("Chi", @as(CodePoint, 0x03A7));
|
||||
jsxEntity.putAssumeCapacity("Psi", @as(CodePoint, 0x03A8));
|
||||
jsxEntity.putAssumeCapacity("Omega", @as(CodePoint, 0x03A9));
|
||||
jsxEntity.putAssumeCapacity("alpha", @as(CodePoint, 0x03B1));
|
||||
jsxEntity.putAssumeCapacity("beta", @as(CodePoint, 0x03B2));
|
||||
jsxEntity.putAssumeCapacity("gamma", @as(CodePoint, 0x03B3));
|
||||
jsxEntity.putAssumeCapacity("delta", @as(CodePoint, 0x03B4));
|
||||
jsxEntity.putAssumeCapacity("epsilon", @as(CodePoint, 0x03B5));
|
||||
jsxEntity.putAssumeCapacity("zeta", @as(CodePoint, 0x03B6));
|
||||
jsxEntity.putAssumeCapacity("eta", @as(CodePoint, 0x03B7));
|
||||
jsxEntity.putAssumeCapacity("theta", @as(CodePoint, 0x03B8));
|
||||
jsxEntity.putAssumeCapacity("iota", @as(CodePoint, 0x03B9));
|
||||
jsxEntity.putAssumeCapacity("kappa", @as(CodePoint, 0x03BA));
|
||||
jsxEntity.putAssumeCapacity("lambda", @as(CodePoint, 0x03BB));
|
||||
jsxEntity.putAssumeCapacity("mu", @as(CodePoint, 0x03BC));
|
||||
jsxEntity.putAssumeCapacity("nu", @as(CodePoint, 0x03BD));
|
||||
jsxEntity.putAssumeCapacity("xi", @as(CodePoint, 0x03BE));
|
||||
jsxEntity.putAssumeCapacity("omicron", @as(CodePoint, 0x03BF));
|
||||
jsxEntity.putAssumeCapacity("pi", @as(CodePoint, 0x03C0));
|
||||
jsxEntity.putAssumeCapacity("rho", @as(CodePoint, 0x03C1));
|
||||
jsxEntity.putAssumeCapacity("sigmaf", @as(CodePoint, 0x03C2));
|
||||
jsxEntity.putAssumeCapacity("sigma", @as(CodePoint, 0x03C3));
|
||||
jsxEntity.putAssumeCapacity("tau", @as(CodePoint, 0x03C4));
|
||||
jsxEntity.putAssumeCapacity("upsilon", @as(CodePoint, 0x03C5));
|
||||
jsxEntity.putAssumeCapacity("phi", @as(CodePoint, 0x03C6));
|
||||
jsxEntity.putAssumeCapacity("chi", @as(CodePoint, 0x03C7));
|
||||
jsxEntity.putAssumeCapacity("psi", @as(CodePoint, 0x03C8));
|
||||
jsxEntity.putAssumeCapacity("omega", @as(CodePoint, 0x03C9));
|
||||
jsxEntity.putAssumeCapacity("thetasym", @as(CodePoint, 0x03D1));
|
||||
jsxEntity.putAssumeCapacity("upsih", @as(CodePoint, 0x03D2));
|
||||
jsxEntity.putAssumeCapacity("piv", @as(CodePoint, 0x03D6));
|
||||
jsxEntity.putAssumeCapacity("ensp", @as(CodePoint, 0x2002));
|
||||
jsxEntity.putAssumeCapacity("emsp", @as(CodePoint, 0x2003));
|
||||
jsxEntity.putAssumeCapacity("thinsp", @as(CodePoint, 0x2009));
|
||||
jsxEntity.putAssumeCapacity("zwnj", @as(CodePoint, 0x200C));
|
||||
jsxEntity.putAssumeCapacity("zwj", @as(CodePoint, 0x200D));
|
||||
jsxEntity.putAssumeCapacity("lrm", @as(CodePoint, 0x200E));
|
||||
jsxEntity.putAssumeCapacity("rlm", @as(CodePoint, 0x200F));
|
||||
jsxEntity.putAssumeCapacity("ndash", @as(CodePoint, 0x2013));
|
||||
jsxEntity.putAssumeCapacity("mdash", @as(CodePoint, 0x2014));
|
||||
jsxEntity.putAssumeCapacity("lsquo", @as(CodePoint, 0x2018));
|
||||
jsxEntity.putAssumeCapacity("rsquo", @as(CodePoint, 0x2019));
|
||||
jsxEntity.putAssumeCapacity("sbquo", @as(CodePoint, 0x201A));
|
||||
jsxEntity.putAssumeCapacity("ldquo", @as(CodePoint, 0x201C));
|
||||
jsxEntity.putAssumeCapacity("rdquo", @as(CodePoint, 0x201D));
|
||||
jsxEntity.putAssumeCapacity("bdquo", @as(CodePoint, 0x201E));
|
||||
jsxEntity.putAssumeCapacity("dagger", @as(CodePoint, 0x2020));
|
||||
jsxEntity.putAssumeCapacity("Dagger", @as(CodePoint, 0x2021));
|
||||
jsxEntity.putAssumeCapacity("bull", @as(CodePoint, 0x2022));
|
||||
jsxEntity.putAssumeCapacity("hellip", @as(CodePoint, 0x2026));
|
||||
jsxEntity.putAssumeCapacity("permil", @as(CodePoint, 0x2030));
|
||||
jsxEntity.putAssumeCapacity("prime", @as(CodePoint, 0x2032));
|
||||
jsxEntity.putAssumeCapacity("Prime", @as(CodePoint, 0x2033));
|
||||
jsxEntity.putAssumeCapacity("lsaquo", @as(CodePoint, 0x2039));
|
||||
jsxEntity.putAssumeCapacity("rsaquo", @as(CodePoint, 0x203A));
|
||||
jsxEntity.putAssumeCapacity("oline", @as(CodePoint, 0x203E));
|
||||
jsxEntity.putAssumeCapacity("frasl", @as(CodePoint, 0x2044));
|
||||
jsxEntity.putAssumeCapacity("euro", @as(CodePoint, 0x20AC));
|
||||
jsxEntity.putAssumeCapacity("image", @as(CodePoint, 0x2111));
|
||||
jsxEntity.putAssumeCapacity("weierp", @as(CodePoint, 0x2118));
|
||||
jsxEntity.putAssumeCapacity("real", @as(CodePoint, 0x211C));
|
||||
jsxEntity.putAssumeCapacity("trade", @as(CodePoint, 0x2122));
|
||||
jsxEntity.putAssumeCapacity("alefsym", @as(CodePoint, 0x2135));
|
||||
jsxEntity.putAssumeCapacity("larr", @as(CodePoint, 0x2190));
|
||||
jsxEntity.putAssumeCapacity("uarr", @as(CodePoint, 0x2191));
|
||||
jsxEntity.putAssumeCapacity("rarr", @as(CodePoint, 0x2192));
|
||||
jsxEntity.putAssumeCapacity("darr", @as(CodePoint, 0x2193));
|
||||
jsxEntity.putAssumeCapacity("harr", @as(CodePoint, 0x2194));
|
||||
jsxEntity.putAssumeCapacity("crarr", @as(CodePoint, 0x21B5));
|
||||
jsxEntity.putAssumeCapacity("lArr", @as(CodePoint, 0x21D0));
|
||||
jsxEntity.putAssumeCapacity("uArr", @as(CodePoint, 0x21D1));
|
||||
jsxEntity.putAssumeCapacity("rArr", @as(CodePoint, 0x21D2));
|
||||
jsxEntity.putAssumeCapacity("dArr", @as(CodePoint, 0x21D3));
|
||||
jsxEntity.putAssumeCapacity("hArr", @as(CodePoint, 0x21D4));
|
||||
jsxEntity.putAssumeCapacity("forall", @as(CodePoint, 0x2200));
|
||||
jsxEntity.putAssumeCapacity("part", @as(CodePoint, 0x2202));
|
||||
jsxEntity.putAssumeCapacity("exist", @as(CodePoint, 0x2203));
|
||||
jsxEntity.putAssumeCapacity("empty", @as(CodePoint, 0x2205));
|
||||
jsxEntity.putAssumeCapacity("nabla", @as(CodePoint, 0x2207));
|
||||
jsxEntity.putAssumeCapacity("isin", @as(CodePoint, 0x2208));
|
||||
jsxEntity.putAssumeCapacity("notin", @as(CodePoint, 0x2209));
|
||||
jsxEntity.putAssumeCapacity("ni", @as(CodePoint, 0x220B));
|
||||
jsxEntity.putAssumeCapacity("prod", @as(CodePoint, 0x220F));
|
||||
jsxEntity.putAssumeCapacity("sum", @as(CodePoint, 0x2211));
|
||||
jsxEntity.putAssumeCapacity("minus", @as(CodePoint, 0x2212));
|
||||
jsxEntity.putAssumeCapacity("lowast", @as(CodePoint, 0x2217));
|
||||
jsxEntity.putAssumeCapacity("radic", @as(CodePoint, 0x221A));
|
||||
jsxEntity.putAssumeCapacity("prop", @as(CodePoint, 0x221D));
|
||||
jsxEntity.putAssumeCapacity("infin", @as(CodePoint, 0x221E));
|
||||
jsxEntity.putAssumeCapacity("ang", @as(CodePoint, 0x2220));
|
||||
jsxEntity.putAssumeCapacity("and", @as(CodePoint, 0x2227));
|
||||
jsxEntity.putAssumeCapacity("or", @as(CodePoint, 0x2228));
|
||||
jsxEntity.putAssumeCapacity("cap", @as(CodePoint, 0x2229));
|
||||
jsxEntity.putAssumeCapacity("cup", @as(CodePoint, 0x222A));
|
||||
jsxEntity.putAssumeCapacity("int", @as(CodePoint, 0x222B));
|
||||
jsxEntity.putAssumeCapacity("there4", @as(CodePoint, 0x2234));
|
||||
jsxEntity.putAssumeCapacity("sim", @as(CodePoint, 0x223C));
|
||||
jsxEntity.putAssumeCapacity("cong", @as(CodePoint, 0x2245));
|
||||
jsxEntity.putAssumeCapacity("asymp", @as(CodePoint, 0x2248));
|
||||
jsxEntity.putAssumeCapacity("ne", @as(CodePoint, 0x2260));
|
||||
jsxEntity.putAssumeCapacity("equiv", @as(CodePoint, 0x2261));
|
||||
jsxEntity.putAssumeCapacity("le", @as(CodePoint, 0x2264));
|
||||
jsxEntity.putAssumeCapacity("ge", @as(CodePoint, 0x2265));
|
||||
jsxEntity.putAssumeCapacity("sub", @as(CodePoint, 0x2282));
|
||||
jsxEntity.putAssumeCapacity("sup", @as(CodePoint, 0x2283));
|
||||
jsxEntity.putAssumeCapacity("nsub", @as(CodePoint, 0x2284));
|
||||
jsxEntity.putAssumeCapacity("sube", @as(CodePoint, 0x2286));
|
||||
jsxEntity.putAssumeCapacity("supe", @as(CodePoint, 0x2287));
|
||||
jsxEntity.putAssumeCapacity("oplus", @as(CodePoint, 0x2295));
|
||||
jsxEntity.putAssumeCapacity("otimes", @as(CodePoint, 0x2297));
|
||||
jsxEntity.putAssumeCapacity("perp", @as(CodePoint, 0x22A5));
|
||||
jsxEntity.putAssumeCapacity("sdot", @as(CodePoint, 0x22C5));
|
||||
jsxEntity.putAssumeCapacity("lceil", @as(CodePoint, 0x2308));
|
||||
jsxEntity.putAssumeCapacity("rceil", @as(CodePoint, 0x2309));
|
||||
jsxEntity.putAssumeCapacity("lfloor", @as(CodePoint, 0x230A));
|
||||
jsxEntity.putAssumeCapacity("rfloor", @as(CodePoint, 0x230B));
|
||||
jsxEntity.putAssumeCapacity("lang", @as(CodePoint, 0x2329));
|
||||
jsxEntity.putAssumeCapacity("rang", @as(CodePoint, 0x232A));
|
||||
jsxEntity.putAssumeCapacity("loz", @as(CodePoint, 0x25CA));
|
||||
jsxEntity.putAssumeCapacity("spades", @as(CodePoint, 0x2660));
|
||||
jsxEntity.putAssumeCapacity("clubs", @as(CodePoint, 0x2663));
|
||||
jsxEntity.putAssumeCapacity("hearts", @as(CodePoint, 0x2665));
|
||||
jsxEntity.putAssumeCapacity("diams", @as(CodePoint, 0x2666));
|
||||
}
|
||||
// In a microbenchmark, this outperforms
|
||||
pub const jsxEntity = ComptimeStringMap(CodePoint, .{
|
||||
.{ "Aacute", @as(CodePoint, 0x00C1) },
|
||||
.{ "aacute", @as(CodePoint, 0x00E1) },
|
||||
.{ "Acirc", @as(CodePoint, 0x00C2) },
|
||||
.{ "acirc", @as(CodePoint, 0x00E2) },
|
||||
.{ "acute", @as(CodePoint, 0x00B4) },
|
||||
.{ "AElig", @as(CodePoint, 0x00C6) },
|
||||
.{ "aelig", @as(CodePoint, 0x00E6) },
|
||||
.{ "Agrave", @as(CodePoint, 0x00C0) },
|
||||
.{ "agrave", @as(CodePoint, 0x00E0) },
|
||||
.{ "alefsym", @as(CodePoint, 0x2135) },
|
||||
.{ "Alpha", @as(CodePoint, 0x0391) },
|
||||
.{ "alpha", @as(CodePoint, 0x03B1) },
|
||||
.{ "amp", @as(CodePoint, 0x0026) },
|
||||
.{ "and", @as(CodePoint, 0x2227) },
|
||||
.{ "ang", @as(CodePoint, 0x2220) },
|
||||
.{ "apos", @as(CodePoint, 0x0027) },
|
||||
.{ "Aring", @as(CodePoint, 0x00C5) },
|
||||
.{ "aring", @as(CodePoint, 0x00E5) },
|
||||
.{ "asymp", @as(CodePoint, 0x2248) },
|
||||
.{ "Atilde", @as(CodePoint, 0x00C3) },
|
||||
.{ "atilde", @as(CodePoint, 0x00E3) },
|
||||
.{ "Auml", @as(CodePoint, 0x00C4) },
|
||||
.{ "auml", @as(CodePoint, 0x00E4) },
|
||||
.{ "bdquo", @as(CodePoint, 0x201E) },
|
||||
.{ "Beta", @as(CodePoint, 0x0392) },
|
||||
.{ "beta", @as(CodePoint, 0x03B2) },
|
||||
.{ "brvbar", @as(CodePoint, 0x00A6) },
|
||||
.{ "bull", @as(CodePoint, 0x2022) },
|
||||
.{ "cap", @as(CodePoint, 0x2229) },
|
||||
.{ "Ccedil", @as(CodePoint, 0x00C7) },
|
||||
.{ "ccedil", @as(CodePoint, 0x00E7) },
|
||||
.{ "cedil", @as(CodePoint, 0x00B8) },
|
||||
.{ "cent", @as(CodePoint, 0x00A2) },
|
||||
.{ "Chi", @as(CodePoint, 0x03A7) },
|
||||
.{ "chi", @as(CodePoint, 0x03C7) },
|
||||
.{ "circ", @as(CodePoint, 0x02C6) },
|
||||
.{ "clubs", @as(CodePoint, 0x2663) },
|
||||
.{ "cong", @as(CodePoint, 0x2245) },
|
||||
.{ "copy", @as(CodePoint, 0x00A9) },
|
||||
.{ "crarr", @as(CodePoint, 0x21B5) },
|
||||
.{ "cup", @as(CodePoint, 0x222A) },
|
||||
.{ "curren", @as(CodePoint, 0x00A4) },
|
||||
.{ "dagger", @as(CodePoint, 0x2020) },
|
||||
.{ "Dagger", @as(CodePoint, 0x2021) },
|
||||
.{ "darr", @as(CodePoint, 0x2193) },
|
||||
.{ "dArr", @as(CodePoint, 0x21D3) },
|
||||
.{ "deg", @as(CodePoint, 0x00B0) },
|
||||
.{ "Delta", @as(CodePoint, 0x0394) },
|
||||
.{ "delta", @as(CodePoint, 0x03B4) },
|
||||
.{ "diams", @as(CodePoint, 0x2666) },
|
||||
.{ "divide", @as(CodePoint, 0x00F7) },
|
||||
.{ "Eacute", @as(CodePoint, 0x00C9) },
|
||||
.{ "eacute", @as(CodePoint, 0x00E9) },
|
||||
.{ "Ecirc", @as(CodePoint, 0x00CA) },
|
||||
.{ "ecirc", @as(CodePoint, 0x00EA) },
|
||||
.{ "Egrave", @as(CodePoint, 0x00C8) },
|
||||
.{ "egrave", @as(CodePoint, 0x00E8) },
|
||||
.{ "empty", @as(CodePoint, 0x2205) },
|
||||
.{ "emsp", @as(CodePoint, 0x2003) },
|
||||
.{ "ensp", @as(CodePoint, 0x2002) },
|
||||
.{ "Epsilon", @as(CodePoint, 0x0395) },
|
||||
.{ "epsilon", @as(CodePoint, 0x03B5) },
|
||||
.{ "equiv", @as(CodePoint, 0x2261) },
|
||||
.{ "Eta", @as(CodePoint, 0x0397) },
|
||||
.{ "eta", @as(CodePoint, 0x03B7) },
|
||||
.{ "ETH", @as(CodePoint, 0x00D0) },
|
||||
.{ "eth", @as(CodePoint, 0x00F0) },
|
||||
.{ "Euml", @as(CodePoint, 0x00CB) },
|
||||
.{ "euml", @as(CodePoint, 0x00EB) },
|
||||
.{ "euro", @as(CodePoint, 0x20AC) },
|
||||
.{ "exist", @as(CodePoint, 0x2203) },
|
||||
.{ "fnof", @as(CodePoint, 0x0192) },
|
||||
.{ "forall", @as(CodePoint, 0x2200) },
|
||||
.{ "frac12", @as(CodePoint, 0x00BD) },
|
||||
.{ "frac14", @as(CodePoint, 0x00BC) },
|
||||
.{ "frac34", @as(CodePoint, 0x00BE) },
|
||||
.{ "frasl", @as(CodePoint, 0x2044) },
|
||||
.{ "Gamma", @as(CodePoint, 0x0393) },
|
||||
.{ "gamma", @as(CodePoint, 0x03B3) },
|
||||
.{ "ge", @as(CodePoint, 0x2265) },
|
||||
.{ "gt", @as(CodePoint, 0x003E) },
|
||||
.{ "harr", @as(CodePoint, 0x2194) },
|
||||
.{ "hArr", @as(CodePoint, 0x21D4) },
|
||||
.{ "hearts", @as(CodePoint, 0x2665) },
|
||||
.{ "hellip", @as(CodePoint, 0x2026) },
|
||||
.{ "Iacute", @as(CodePoint, 0x00CD) },
|
||||
.{ "iacute", @as(CodePoint, 0x00ED) },
|
||||
.{ "Icirc", @as(CodePoint, 0x00CE) },
|
||||
.{ "icirc", @as(CodePoint, 0x00EE) },
|
||||
.{ "iexcl", @as(CodePoint, 0x00A1) },
|
||||
.{ "Igrave", @as(CodePoint, 0x00CC) },
|
||||
.{ "igrave", @as(CodePoint, 0x00EC) },
|
||||
.{ "image", @as(CodePoint, 0x2111) },
|
||||
.{ "infin", @as(CodePoint, 0x221E) },
|
||||
.{ "int", @as(CodePoint, 0x222B) },
|
||||
.{ "Iota", @as(CodePoint, 0x0399) },
|
||||
.{ "iota", @as(CodePoint, 0x03B9) },
|
||||
.{ "iquest", @as(CodePoint, 0x00BF) },
|
||||
.{ "isin", @as(CodePoint, 0x2208) },
|
||||
.{ "Iuml", @as(CodePoint, 0x00CF) },
|
||||
.{ "iuml", @as(CodePoint, 0x00EF) },
|
||||
.{ "Kappa", @as(CodePoint, 0x039A) },
|
||||
.{ "kappa", @as(CodePoint, 0x03BA) },
|
||||
.{ "Lambda", @as(CodePoint, 0x039B) },
|
||||
.{ "lambda", @as(CodePoint, 0x03BB) },
|
||||
.{ "lang", @as(CodePoint, 0x2329) },
|
||||
.{ "laquo", @as(CodePoint, 0x00AB) },
|
||||
.{ "larr", @as(CodePoint, 0x2190) },
|
||||
.{ "lArr", @as(CodePoint, 0x21D0) },
|
||||
.{ "lceil", @as(CodePoint, 0x2308) },
|
||||
.{ "ldquo", @as(CodePoint, 0x201C) },
|
||||
.{ "le", @as(CodePoint, 0x2264) },
|
||||
.{ "lfloor", @as(CodePoint, 0x230A) },
|
||||
.{ "lowast", @as(CodePoint, 0x2217) },
|
||||
.{ "loz", @as(CodePoint, 0x25CA) },
|
||||
.{ "lrm", @as(CodePoint, 0x200E) },
|
||||
.{ "lsaquo", @as(CodePoint, 0x2039) },
|
||||
.{ "lsquo", @as(CodePoint, 0x2018) },
|
||||
.{ "lt", @as(CodePoint, 0x003C) },
|
||||
.{ "macr", @as(CodePoint, 0x00AF) },
|
||||
.{ "mdash", @as(CodePoint, 0x2014) },
|
||||
.{ "micro", @as(CodePoint, 0x00B5) },
|
||||
.{ "middot", @as(CodePoint, 0x00B7) },
|
||||
.{ "minus", @as(CodePoint, 0x2212) },
|
||||
.{ "Mu", @as(CodePoint, 0x039C) },
|
||||
.{ "mu", @as(CodePoint, 0x03BC) },
|
||||
.{ "nabla", @as(CodePoint, 0x2207) },
|
||||
.{ "nbsp", @as(CodePoint, 0x00A0) },
|
||||
.{ "ndash", @as(CodePoint, 0x2013) },
|
||||
.{ "ne", @as(CodePoint, 0x2260) },
|
||||
.{ "ni", @as(CodePoint, 0x220B) },
|
||||
.{ "not", @as(CodePoint, 0x00AC) },
|
||||
.{ "notin", @as(CodePoint, 0x2209) },
|
||||
.{ "nsub", @as(CodePoint, 0x2284) },
|
||||
.{ "Ntilde", @as(CodePoint, 0x00D1) },
|
||||
.{ "ntilde", @as(CodePoint, 0x00F1) },
|
||||
.{ "Nu", @as(CodePoint, 0x039D) },
|
||||
.{ "nu", @as(CodePoint, 0x03BD) },
|
||||
.{ "Oacute", @as(CodePoint, 0x00D3) },
|
||||
.{ "oacute", @as(CodePoint, 0x00F3) },
|
||||
.{ "Ocirc", @as(CodePoint, 0x00D4) },
|
||||
.{ "ocirc", @as(CodePoint, 0x00F4) },
|
||||
.{ "OElig", @as(CodePoint, 0x0152) },
|
||||
.{ "oelig", @as(CodePoint, 0x0153) },
|
||||
.{ "Ograve", @as(CodePoint, 0x00D2) },
|
||||
.{ "ograve", @as(CodePoint, 0x00F2) },
|
||||
.{ "oline", @as(CodePoint, 0x203E) },
|
||||
.{ "Omega", @as(CodePoint, 0x03A9) },
|
||||
.{ "omega", @as(CodePoint, 0x03C9) },
|
||||
.{ "Omicron", @as(CodePoint, 0x039F) },
|
||||
.{ "omicron", @as(CodePoint, 0x03BF) },
|
||||
.{ "oplus", @as(CodePoint, 0x2295) },
|
||||
.{ "or", @as(CodePoint, 0x2228) },
|
||||
.{ "ordf", @as(CodePoint, 0x00AA) },
|
||||
.{ "ordm", @as(CodePoint, 0x00BA) },
|
||||
.{ "Oslash", @as(CodePoint, 0x00D8) },
|
||||
.{ "oslash", @as(CodePoint, 0x00F8) },
|
||||
.{ "Otilde", @as(CodePoint, 0x00D5) },
|
||||
.{ "otilde", @as(CodePoint, 0x00F5) },
|
||||
.{ "otimes", @as(CodePoint, 0x2297) },
|
||||
.{ "Ouml", @as(CodePoint, 0x00D6) },
|
||||
.{ "ouml", @as(CodePoint, 0x00F6) },
|
||||
.{ "para", @as(CodePoint, 0x00B6) },
|
||||
.{ "part", @as(CodePoint, 0x2202) },
|
||||
.{ "permil", @as(CodePoint, 0x2030) },
|
||||
.{ "perp", @as(CodePoint, 0x22A5) },
|
||||
.{ "Phi", @as(CodePoint, 0x03A6) },
|
||||
.{ "phi", @as(CodePoint, 0x03C6) },
|
||||
.{ "Pi", @as(CodePoint, 0x03A0) },
|
||||
.{ "pi", @as(CodePoint, 0x03C0) },
|
||||
.{ "piv", @as(CodePoint, 0x03D6) },
|
||||
.{ "plusmn", @as(CodePoint, 0x00B1) },
|
||||
.{ "pound", @as(CodePoint, 0x00A3) },
|
||||
.{ "prime", @as(CodePoint, 0x2032) },
|
||||
.{ "Prime", @as(CodePoint, 0x2033) },
|
||||
.{ "prod", @as(CodePoint, 0x220F) },
|
||||
.{ "prop", @as(CodePoint, 0x221D) },
|
||||
.{ "Psi", @as(CodePoint, 0x03A8) },
|
||||
.{ "psi", @as(CodePoint, 0x03C8) },
|
||||
.{ "quot", @as(CodePoint, 0x0022) },
|
||||
.{ "radic", @as(CodePoint, 0x221A) },
|
||||
.{ "rang", @as(CodePoint, 0x232A) },
|
||||
.{ "raquo", @as(CodePoint, 0x00BB) },
|
||||
.{ "rarr", @as(CodePoint, 0x2192) },
|
||||
.{ "rArr", @as(CodePoint, 0x21D2) },
|
||||
.{ "rceil", @as(CodePoint, 0x2309) },
|
||||
.{ "rdquo", @as(CodePoint, 0x201D) },
|
||||
.{ "real", @as(CodePoint, 0x211C) },
|
||||
.{ "reg", @as(CodePoint, 0x00AE) },
|
||||
.{ "rfloor", @as(CodePoint, 0x230B) },
|
||||
.{ "Rho", @as(CodePoint, 0x03A1) },
|
||||
.{ "rho", @as(CodePoint, 0x03C1) },
|
||||
.{ "rlm", @as(CodePoint, 0x200F) },
|
||||
.{ "rsaquo", @as(CodePoint, 0x203A) },
|
||||
.{ "rsquo", @as(CodePoint, 0x2019) },
|
||||
.{ "sbquo", @as(CodePoint, 0x201A) },
|
||||
.{ "Scaron", @as(CodePoint, 0x0160) },
|
||||
.{ "scaron", @as(CodePoint, 0x0161) },
|
||||
.{ "sdot", @as(CodePoint, 0x22C5) },
|
||||
.{ "sect", @as(CodePoint, 0x00A7) },
|
||||
.{ "shy", @as(CodePoint, 0x00AD) },
|
||||
.{ "Sigma", @as(CodePoint, 0x03A3) },
|
||||
.{ "sigma", @as(CodePoint, 0x03C3) },
|
||||
.{ "sigmaf", @as(CodePoint, 0x03C2) },
|
||||
.{ "sim", @as(CodePoint, 0x223C) },
|
||||
.{ "spades", @as(CodePoint, 0x2660) },
|
||||
.{ "sub", @as(CodePoint, 0x2282) },
|
||||
.{ "sube", @as(CodePoint, 0x2286) },
|
||||
.{ "sum", @as(CodePoint, 0x2211) },
|
||||
.{ "sup", @as(CodePoint, 0x2283) },
|
||||
.{ "sup1", @as(CodePoint, 0x00B9) },
|
||||
.{ "sup2", @as(CodePoint, 0x00B2) },
|
||||
.{ "sup3", @as(CodePoint, 0x00B3) },
|
||||
.{ "supe", @as(CodePoint, 0x2287) },
|
||||
.{ "szlig", @as(CodePoint, 0x00DF) },
|
||||
.{ "Tau", @as(CodePoint, 0x03A4) },
|
||||
.{ "tau", @as(CodePoint, 0x03C4) },
|
||||
.{ "there4", @as(CodePoint, 0x2234) },
|
||||
.{ "Theta", @as(CodePoint, 0x0398) },
|
||||
.{ "theta", @as(CodePoint, 0x03B8) },
|
||||
.{ "thetasym", @as(CodePoint, 0x03D1) },
|
||||
.{ "thinsp", @as(CodePoint, 0x2009) },
|
||||
.{ "THORN", @as(CodePoint, 0x00DE) },
|
||||
.{ "thorn", @as(CodePoint, 0x00FE) },
|
||||
.{ "tilde", @as(CodePoint, 0x02DC) },
|
||||
.{ "times", @as(CodePoint, 0x00D7) },
|
||||
.{ "trade", @as(CodePoint, 0x2122) },
|
||||
.{ "Uacute", @as(CodePoint, 0x00DA) },
|
||||
.{ "uacute", @as(CodePoint, 0x00FA) },
|
||||
.{ "uarr", @as(CodePoint, 0x2191) },
|
||||
.{ "uArr", @as(CodePoint, 0x21D1) },
|
||||
.{ "Ucirc", @as(CodePoint, 0x00DB) },
|
||||
.{ "ucirc", @as(CodePoint, 0x00FB) },
|
||||
.{ "Ugrave", @as(CodePoint, 0x00D9) },
|
||||
.{ "ugrave", @as(CodePoint, 0x00F9) },
|
||||
.{ "uml", @as(CodePoint, 0x00A8) },
|
||||
.{ "upsih", @as(CodePoint, 0x03D2) },
|
||||
.{ "Upsilon", @as(CodePoint, 0x03A5) },
|
||||
.{ "upsilon", @as(CodePoint, 0x03C5) },
|
||||
.{ "Uuml", @as(CodePoint, 0x00DC) },
|
||||
.{ "uuml", @as(CodePoint, 0x00FC) },
|
||||
.{ "weierp", @as(CodePoint, 0x2118) },
|
||||
.{ "Xi", @as(CodePoint, 0x039E) },
|
||||
.{ "xi", @as(CodePoint, 0x03BE) },
|
||||
.{ "Yacute", @as(CodePoint, 0x00DD) },
|
||||
.{ "yacute", @as(CodePoint, 0x00FD) },
|
||||
.{ "yen", @as(CodePoint, 0x00A5) },
|
||||
.{ "yuml", @as(CodePoint, 0x00FF) },
|
||||
.{ "Yuml", @as(CodePoint, 0x0178) },
|
||||
.{ "Zeta", @as(CodePoint, 0x0396) },
|
||||
.{ "zeta", @as(CodePoint, 0x03B6) },
|
||||
.{ "zwj", @as(CodePoint, 0x200D) },
|
||||
.{ "zwnj", @as(CodePoint, 0x200C) },
|
||||
});
|
||||
|
||||
test "tokenToString" {
|
||||
try expectString(tokenToString.get(T.t_end_of_file), "end of file");
|
||||
|
||||
Reference in New Issue
Block a user