cache.rs 5.8 KB

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