From: Jukka Kurkela Date: Fri, 3 Jan 2020 18:57:25 +0000 (+0200) Subject: Small optimizations (#6868) X-Git-Tag: v3.0.0-alpha~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=099e552e6ddd2556d31bda5526b10042176d07a0;p=thirdparty%2FChart.js.git Small optimizations (#6868) * Only extend element if configuration is provided * Time scale lookup optimization --- diff --git a/src/core/core.element.js b/src/core/core.element.js index fb2e442c3..6c9fc63ab 100644 --- a/src/core/core.element.js +++ b/src/core/core.element.js @@ -6,7 +6,9 @@ import {isNumber} from '../helpers/helpers.math'; class Element { constructor(configuration) { - extend(this, configuration); + if (configuration) { + extend(this, configuration); + } // this.hidden = false; we assume Element has an attribute called hidden, but do not initialize to save memory } diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 92b6a2006..d98b7816e 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -138,7 +138,7 @@ function lookup(table, key, value) { while (lo >= 0 && lo <= hi) { mid = (lo + hi) >> 1; - i0 = table[mid - 1] || null; + i0 = mid > 0 && table[mid - 1] || null; i1 = table[mid]; if (!i0) {