From e6a72b794c8bcb458f4132cec279b19f75e2cc3b Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 29 Sep 2015 15:16:49 +0200 Subject: [PATCH] Temporarily disable caching from yardstick This will enable us to avoid worrying about cache invalidation while integrating `LinesYardstick` into `TextEditorPresenter`. --- src/lines-yardstick.coffee | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/lines-yardstick.coffee b/src/lines-yardstick.coffee index 0ec946413..d35e5bfa6 100644 --- a/src/lines-yardstick.coffee +++ b/src/lines-yardstick.coffee @@ -5,25 +5,12 @@ AcceptFilter = {acceptNode: -> NodeFilter.FILTER_ACCEPT} module.exports = class LinesYardstick constructor: (@model, @presenter, @lineNodesProvider) -> - @cachedPositionsByLineId = {} @tokenIterator = new TokenIterator @rangeForMeasurement = document.createRange() - clearCache: -> - @cachedPositionsByLineId = {} - prepareScreenRowsForMeasurement: (screenRows) -> @presenter.setScreenRowsToMeasure(screenRows) - @lineNodesProvider.updateSync(@presenter.getStateForMeasurements()) - - cleanup: -> - @presenter.clearScreenRowsToMeasure() - @lineNodesProvider.updateSync(@presenter.getStateForMeasurements()) - - measure: (screenRows, fn) -> - @prepareScreenRowsForMeasurement(screenRows) - fn() - @cleanup() + @lineNodesProvider.updateSync(@presenter.getPreMeasurementState()) pixelPositionForScreenPosition: (screenPosition, clip=true) -> screenPosition = Point.fromObject(screenPosition) @@ -42,9 +29,6 @@ class LinesYardstick tokenizedLine = @model.tokenizedLineForScreenRow(row) return 0 unless tokenizedLine? - if cachedPosition = @cachedPositionsByLineId[tokenizedLine.id]?[column] - return cachedPosition - lineNode = @lineNodesProvider.lineNodeForLineIdAndScreenRow(tokenizedLine.id, row) @@ -91,9 +75,7 @@ class LinesYardstick if textNode? foundIndexWithinTextNode ?= textNode.textContent.length - @cachedPositionsByLineId[tokenizedLine.id] ?= {} - @cachedPositionsByLineId[tokenizedLine.id][column] = - @leftPixelPositionForCharInTextNode(lineNode, textNode, foundIndexWithinTextNode) + @leftPixelPositionForCharInTextNode(lineNode, textNode, foundIndexWithinTextNode) else 0