cache.rs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /// Wasm-bindgen has a performance option to intern commonly used phrases
  2. /// This saves the decoding cost, making the interaction of Rust<->JS more performant.
  3. /// We intern all the HTML tags and attributes, making most operations much faster.
  4. ///
  5. /// Interning takes about 1ms at the start of the app, but saves a *ton* of time later on.
  6. pub fn intern_cache() {
  7. let cached_words = [
  8. // All the HTML Tags
  9. "a",
  10. "abbr",
  11. "address",
  12. "area",
  13. "article",
  14. "aside",
  15. "audio",
  16. "b",
  17. "base",
  18. "bdi",
  19. "bdo",
  20. "big",
  21. "blockquote",
  22. "body",
  23. "br",
  24. "button",
  25. "canvas",
  26. "caption",
  27. "cite",
  28. "code",
  29. "col",
  30. "colgroup",
  31. "command",
  32. "data",
  33. "datalist",
  34. "dd",
  35. "del",
  36. "details",
  37. "dfn",
  38. "dialog",
  39. "div",
  40. "dl",
  41. "dt",
  42. "em",
  43. "embed",
  44. "fieldset",
  45. "figcaption",
  46. "figure",
  47. "footer",
  48. "form",
  49. "h1",
  50. "h2",
  51. "h3",
  52. "h4",
  53. "h5",
  54. "h6",
  55. "head",
  56. "header",
  57. "hr",
  58. "html",
  59. "i",
  60. "iframe",
  61. "img",
  62. "input",
  63. "ins",
  64. "kbd",
  65. "keygen",
  66. "label",
  67. "legend",
  68. "li",
  69. "link",
  70. "main",
  71. "map",
  72. "mark",
  73. "menu",
  74. "menuitem",
  75. "meta",
  76. "meter",
  77. "nav",
  78. "noscript",
  79. "object",
  80. "ol",
  81. "optgroup",
  82. "option",
  83. "output",
  84. "p",
  85. "param",
  86. "picture",
  87. "pre",
  88. "progress",
  89. "q",
  90. "rp",
  91. "rt",
  92. "ruby",
  93. "s",
  94. "samp",
  95. "script",
  96. "section",
  97. "select",
  98. "small",
  99. "source",
  100. "span",
  101. "strong",
  102. "style",
  103. "sub",
  104. "summary",
  105. "sup",
  106. "table",
  107. "tbody",
  108. "td",
  109. "textarea",
  110. "tfoot",
  111. "th",
  112. "thead",
  113. "time",
  114. "title",
  115. "tr",
  116. "track",
  117. "u",
  118. "ul",
  119. "var",
  120. "video",
  121. "wbr",
  122. // All the event handlers
  123. "Attribute",
  124. "accept",
  125. "accept-charset",
  126. "accesskey",
  127. "action",
  128. "alt",
  129. "async",
  130. "autocomplete",
  131. "autofocus",
  132. "autoplay",
  133. "charset",
  134. "checked",
  135. "cite",
  136. "class",
  137. "cols",
  138. "colspan",
  139. "content",
  140. "contenteditable",
  141. "controls",
  142. "coords",
  143. "data",
  144. "data-*",
  145. "datetime",
  146. "default",
  147. "defer",
  148. "dir",
  149. "dirname",
  150. "disabled",
  151. "download",
  152. "draggable",
  153. "enctype",
  154. "for",
  155. "form",
  156. "formaction",
  157. "headers",
  158. "height",
  159. "hidden",
  160. "high",
  161. "href",
  162. "hreflang",
  163. "http-equiv",
  164. "id",
  165. "ismap",
  166. "kind",
  167. "label",
  168. "lang",
  169. "list",
  170. "loop",
  171. "low",
  172. "max",
  173. "maxlength",
  174. "media",
  175. "method",
  176. "min",
  177. "multiple",
  178. "muted",
  179. "name",
  180. "novalidate",
  181. "onabort",
  182. "onafterprint",
  183. "onbeforeprint",
  184. "onbeforeunload",
  185. "onblur",
  186. "oncanplay",
  187. "oncanplaythrough",
  188. "onchange",
  189. "onclick",
  190. "oncontextmenu",
  191. "oncopy",
  192. "oncuechange",
  193. "oncut",
  194. "ondblclick",
  195. "ondrag",
  196. "ondragend",
  197. "ondragenter",
  198. "ondragleave",
  199. "ondragover",
  200. "ondragstart",
  201. "ondrop",
  202. "ondurationchange",
  203. "onemptied",
  204. "onended",
  205. "onerror",
  206. "onfocus",
  207. "onhashchange",
  208. "oninput",
  209. "oninvalid",
  210. "onkeydown",
  211. "onkeypress",
  212. "onkeyup",
  213. "onload",
  214. "onloadeddata",
  215. "onloadedmetadata",
  216. "onloadstart",
  217. "onmousedown",
  218. "onmousemove",
  219. "onmouseout",
  220. "onmouseover",
  221. "onmouseup",
  222. "onmousewheel",
  223. "onoffline",
  224. "ononline",
  225. "<body>",
  226. "onpageshow",
  227. "onpaste",
  228. "onpause",
  229. "onplay",
  230. "onplaying",
  231. "<body>",
  232. "onprogress",
  233. "onratechange",
  234. "onreset",
  235. "onresize",
  236. "onscroll",
  237. "onsearch",
  238. "onseeked",
  239. "onseeking",
  240. "onselect",
  241. "onstalled",
  242. "<body>",
  243. "onsubmit",
  244. "onsuspend",
  245. "ontimeupdate",
  246. "ontoggle",
  247. "onunload",
  248. "onvolumechange",
  249. "onwaiting",
  250. "onwheel",
  251. "open",
  252. "optimum",
  253. "pattern",
  254. "placeholder",
  255. "poster",
  256. "preload",
  257. "readonly",
  258. "rel",
  259. "required",
  260. "reversed",
  261. "rows",
  262. "rowspan",
  263. "sandbox",
  264. "scope",
  265. "selected",
  266. "shape",
  267. "size",
  268. "sizes",
  269. "span",
  270. "spellcheck",
  271. "src",
  272. "srcdoc",
  273. "srclang",
  274. "srcset",
  275. "start",
  276. "step",
  277. "style",
  278. "tabindex",
  279. "target",
  280. "title",
  281. "translate",
  282. "type",
  283. "usemap",
  284. "value",
  285. "width",
  286. "wrap",
  287. ];
  288. for s in cached_words {
  289. wasm_bindgen::intern(s);
  290. }
  291. }