From 4d9c84bfea91a1e22bbc4b94dd3bbae77af0e2e2 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 20 Apr 2018 12:48:51 +1000 Subject: Backport: Use std::count to simplify code. Avoid NULL. Backport of changeset 6720:a53006dc13cd. --- src/CallTip.cxx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/CallTip.cxx b/src/CallTip.cxx index 07188929c..f8bb77c48 100644 --- a/src/CallTip.cxx +++ b/src/CallTip.cxx @@ -185,7 +185,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { while (moreChunks) { const char *chunkEnd = strchr(chunkVal, '\n'); - if (chunkEnd == NULL) { + if (!chunkEnd) { chunkEnd = chunkVal + strlen(chunkVal); moreChunks = false; } @@ -271,17 +271,11 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co font.Create(fp); // Look for multiple lines in the text // Only support \n here - simply means container must avoid \r! - int numLines = 1; - const char *newline; - const char *look = val.c_str(); + const int numLines = 1 + static_cast(std::count(val.begin(), val.end(), '\n')); rectUp = PRectangle(0,0,0,0); rectDown = PRectangle(0,0,0,0); offsetMain = insetX; // changed to right edge of any arrows const int width = PaintContents(surfaceMeasure.get(), false) + insetX; - while ((newline = strchr(look, '\n')) != NULL) { - look = newline + 1; - numLines++; - } lineHeight = static_cast(lround(surfaceMeasure->Height(font))); // The returned -- cgit v1.2.3