]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Small optimizations (#6868)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Fri, 3 Jan 2020 18:57:25 +0000 (20:57 +0200)
committerEvert Timberg <evert.timberg+github@gmail.com>
Fri, 3 Jan 2020 18:57:25 +0000 (13:57 -0500)
* Only extend element if configuration is provided

* Time scale lookup optimization

src/core/core.element.js
src/scales/scale.time.js

index fb2e442c37f899e027b16dcd779eebac75dab280..6c9fc63aba470a842802d726bdc1c594a1b69ad0 100644 (file)
@@ -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
        }
index 92b6a200612df411672deec34f6970b34b4dfd8a..d98b7816e308d542803a20a37f9c9a452f7dc0aa 100644 (file)
@@ -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) {