From 2e1f780cf9fb70aef2e8fcb2e4c8fd74b01c4d97 Mon Sep 17 00:00:00 2001 From: Grzegorz Bera Date: Fri, 10 Apr 2015 10:39:31 +0200 Subject: [PATCH] small optimization --- src/handsontable.formula.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/handsontable.formula.js b/src/handsontable.formula.js index 2c0cd1d..7201d0e 100644 --- a/src/handsontable.formula.js +++ b/src/handsontable.formula.js @@ -3,8 +3,18 @@ function HandsontableFormula() { + var isFormula = function (value) { + if (value) { + if (value[0] === '=') { + return true; + } + } + + return false; + }; + var formulaRenderer = function (instance, TD, row, col, prop, value, cellProperties) { - if (instance.formulasEnabled) { + if (instance.formulasEnabled && isFormula(value)) { // translate coordinates into cellId var cellId = instance.plugin.utils.translateCellCoords({row: row, col: col}), prevFormula = null, @@ -57,6 +67,7 @@ // parse formula var newValue = instance.plugin.parse(formula, {row: row, col: col, id: cellId}); + // check if update needed needUpdate = (newValue.error === '#NEED_UPDATE'); // update item value and error