From 099e552e6ddd2556d31bda5526b10042176d07a0 Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Fri, 3 Jan 2020 20:57:25 +0200 Subject: [PATCH] Small optimizations (#6868) * Only extend element if configuration is provided * Time scale lookup optimization --- src/core/core.element.js | 4 +++- src/scales/scale.time.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) 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) { -- 2.47.2