3 ms·
> type: "CREATE" | "REMOVE" | "CHANGE"; Since performance is a goal, why not define an enum and use integer values? I don't know about speed, but the resulting
by laurent123456 5y ago
> type: "CREATE" | "REMOVE" | "CHANGE";
Since performance is a goal, why not define an enum and use integer values? I don't know about speed, but the resulting diff would be smaller.
Also I wonder what "const t = true" is for.
- wruza 5y agoUsually it doesn’t make a difference neither in speed, nor in size, because of “interning” of literals. Unless you jsonify it, of course. It could show up, if you’d later compare .type with some “CRE”+”ATE” values made funny way, but not for literals, e.g.: // x.js export const foo = "foo" // y.js if (x.foo === "foo") { // ^ as cheap as int } const foo2 = "FOO".toLowerCase() if (x.foo === foo2) { // ^ questionable // depends on jit/optimization } https://stackoverflow.com/questions/5276915/do-common-javascript-implementations-use-string-interning https://stackoverflow.com/questions/5276915/do-common-javasc... https://en.wikipedia.org/wiki/String_interning https://en.wikipedia.org/wiki/String_interning