Optimize category parse for usual use case (#6959)

This commit is contained in:
Jukka Kurkela 2020-01-15 01:22:17 +02:00 committed by Evert Timberg
parent a1c2dd6fb6
commit dc638d36e3

View File

@ -8,6 +8,9 @@ const defaultConfig = {
class CategoryScale extends Scale {
_parse(raw, index) {
const labels = this._getLabels();
if (labels[index] === raw) {
return index;
}
const first = labels.indexOf(raw);
const last = labels.lastIndexOf(raw);
return first === -1 || first !== last ? index : first;