diff --git a/lib/core/segments.js b/lib/core/segments.js index ba8be178..43dbfd2b 100644 --- a/lib/core/segments.js +++ b/lib/core/segments.js @@ -202,12 +202,12 @@ function buildGraph (nodes, version) { getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode) - table[prevNodeId].lastCount += node.length + table[key].lastCount += node.length } else { - if (table[prevNodeId]) table[prevNodeId].lastCount = node.length - graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version) // switch cost + + table[key].lastCount = node.length } } }