use Object rather than Map to store color cache

This commit is contained in:
bkmartinjr
2018-05-08 10:31:42 -07:00
parent c9ff8b35c2
commit 783b7a46f1
+3 -3
View File
@@ -5,7 +5,7 @@ import { scaleRGB } from "./scaleRGB";
// to do this operation. This lets us have speed, but keep the pleasant ability // to do this operation. This lets us have speed, but keep the pleasant ability
// to talk about colors by their text description eg, 'rgb(0,0,1)' // to talk about colors by their text description eg, 'rgb(0,0,1)'
// //
const colorCache = new Map(); const colorCache = new Object(null); // no prototype
function parseColorName(c) { function parseColorName(c) {
if (c[0] !== "#") { if (c[0] !== "#") {
@@ -22,10 +22,10 @@ function parseColorName(c) {
} }
export const parseRGB = c => { export const parseRGB = c => {
var cv = colorCache.get(c); var cv = colorCache[c];
if (!cv) { if (!cv) {
cv = parseColorName(c); cv = parseColorName(c);
colorCache.set(c, cv); colorCache[c] = cv;
} }
return cv; return cv;
}; };