diff options
author | Neil <nyamatongwe@gmail.com> | 2018-04-20 12:48:51 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2018-04-20 12:48:51 +1000 |
commit | 96574354e494ab49f27d137b18d7105436284eda (patch) | |
tree | cc112bcdf5960923e1fd789a915ae8b54c36ac2a /src | |
parent | 1523de1d2127f9bc8090e10a1ab1d0bce2af3c03 (diff) | |
download | scintilla-mirror-96574354e494ab49f27d137b18d7105436284eda.tar.gz |
Use std::count to simplify code. Avoid NULL.
Diffstat (limited to 'src')
-rw-r--r-- | src/CallTip.cxx | 10 |
1 files changed, 2 insertions, 8 deletions
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<int>(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<int>(lround(surfaceMeasure->Height(font))); // The returned |