From dc0ddcfa9fc9534a1945a8744936dca6f5369409 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 21 May 2024 22:59:02 +0200 Subject: [PATCH] Move text blocks first also in stats counter as an optimisation --- novelwriter/core/tokenizer.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/novelwriter/core/tokenizer.py b/novelwriter/core/tokenizer.py index df85b8a2..448cb2ed 100644 --- a/novelwriter/core/tokenizer.py +++ b/novelwriter/core/tokenizer.py @@ -926,21 +926,7 @@ class Tokenizer(ABC): nChars = len(tText) nWChars = len("".join(tWords)) - if tType in self.L_HEADINGS: - titleCount += 1 - allWords += nWords - titleWords += nWords - allChars += nChars - allWordChars += nWChars - titleChars += nChars - titleWordChars += nWChars - - elif tType == self.T_SEP: - allWords += nWords - allChars += nChars - allWordChars += nWChars - - elif tType == self.T_TEXT: + if tType == self.T_TEXT: tPWords = tText.split() nPWords = len(tPWords) nPChars = len(tText) @@ -954,6 +940,20 @@ class Tokenizer(ABC): allWordChars += nPWChars textWordChars += nPWChars + elif tType in self.L_HEADINGS: + titleCount += 1 + allWords += nWords + titleWords += nWords + allChars += nChars + allWordChars += nWChars + titleChars += nChars + titleWordChars += nWChars + + elif tType == self.T_SEP: + allWords += nWords + allChars += nChars + allWordChars += nWChars + elif tType == self.T_SYNOPSIS and self._doSynopsis: text = "{0}: {1}".format(self._localLookup("Synopsis"), tText) words = text.split()