Remove format/parse cache

Remove the cache for formatted and parsed values, as this was
a net performance loss due to a very low cache hit percentage.
This commit is contained in:
Pete Richards 2017-04-21 12:48:21 -07:00 committed by Victor Woeltjen
parent 9e12886c66
commit 1378b57567

View File

@ -41,8 +41,6 @@ define([
};
this.valueMetadata = valueMetadata;
this.parseCache = new WeakMap();
this.formatCache = new WeakMap();
try {
this.formatter = formatService
.getFormat(valueMetadata.format, valueMetadata);
@ -72,26 +70,14 @@ define([
TelemetryValueFormatter.prototype.parse = function (datum) {
if (_.isObject(datum)) {
if (!this.parseCache.has(datum)) {
this.parseCache.set(
datum,
this.formatter.parse(datum[this.valueMetadata.source])
);
}
return this.parseCache.get(datum);
return this.formatter.parse(datum[this.valueMetadata.source]);
}
return this.formatter.parse(datum);
};
TelemetryValueFormatter.prototype.format = function (datum) {
if (_.isObject(datum)) {
if (!this.formatCache.has(datum)) {
this.formatCache.set(
datum,
this.formatter.format(datum[this.valueMetadata.source])
);
}
return this.formatCache.get(datum);
return this.formatter.format(datum[this.valueMetadata.source]);
}
return this.formatter.format(datum);
};