From 4e19675d86a4e9102b1aef5d16df3977d4ef2b61 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 8 Apr 2025 09:55:08 +1000 Subject: Simplify code and fix impossible INTEGER_OVERFLOW warning from Coverity. --- src/Document.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Document.cxx b/src/Document.cxx index b4fa617b2..027790303 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -632,14 +632,14 @@ constexpr bool IsSubordinate(FoldLevel levelStart, FoldLevel levelTry) noexcept Sci::Line Document::GetLastChild(Sci::Line lineParent, std::optional level, Sci::Line lastLine) { const FoldLevel levelStart = LevelNumberPart(level ? *level : GetFoldLevel(lineParent)); - const Sci::Line maxLine = LinesTotal(); - const Sci::Line lookLastLine = (lastLine != -1) ? std::min(LinesTotal() - 1, lastLine) : -1; + const Sci::Line maxLine = LinesTotal() - 1; + const Sci::Line lookLastLine = (lastLine != -1) ? std::min(maxLine, lastLine) : maxLine; Sci::Line lineMaxSubord = lineParent; - while (lineMaxSubord < maxLine - 1) { + while (lineMaxSubord < maxLine) { EnsureStyledTo(LineStart(lineMaxSubord + 2)); if (!IsSubordinate(levelStart, GetFoldLevel(lineMaxSubord + 1))) break; - if ((lookLastLine != -1) && (lineMaxSubord >= lookLastLine) && !LevelIsWhitespace(GetFoldLevel(lineMaxSubord))) + if ((lineMaxSubord >= lookLastLine) && !LevelIsWhitespace(GetFoldLevel(lineMaxSubord))) break; lineMaxSubord++; } -- cgit v1.2.3