From: Evert Timberg Date: Mon, 28 Dec 2020 08:19:16 +0000 (-0500) Subject: Cache the lineheight regex (#8240) X-Git-Tag: v3.0.0-beta.8~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78e78256a5e2630b2bba644a8d48ec1674220179;p=thirdparty%2FChart.js.git Cache the lineheight regex (#8240) --- diff --git a/src/helpers/helpers.options.js b/src/helpers/helpers.options.js index 8a445f6e9..2b01d518e 100644 --- a/src/helpers/helpers.options.js +++ b/src/helpers/helpers.options.js @@ -2,6 +2,8 @@ import defaults from '../core/core.defaults'; import {isArray, isObject, valueOrDefault} from './helpers.core'; import {toFontString} from './helpers.canvas'; +const LINE_HEIGHT = new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/); + /** * @alias Chart.helpers.options * @namespace @@ -15,7 +17,7 @@ import {toFontString} from './helpers.canvas'; * @since 2.7.0 */ export function toLineHeight(value, size) { - const matches = ('' + value).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/); + const matches = ('' + value).match(LINE_HEIGHT); if (!matches || matches[1] === 'normal') { return size * 1.2; }