aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/CallTip.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-04-20 12:48:51 +1000
committerNeil <nyamatongwe@gmail.com>2018-04-20 12:48:51 +1000
commit4d9c84bfea91a1e22bbc4b94dd3bbae77af0e2e2 (patch)
treeaea3c73449ec0f1c3bcf70e6270641a54a749f7b /src/CallTip.cxx
parent02b15b44eb8dab735f004fd57db75842f42ea194 (diff)
downloadscintilla-mirror-4d9c84bfea91a1e22bbc4b94dd3bbae77af0e2e2.tar.gz
Backport: Use std::count to simplify code. Avoid NULL.
Backport of changeset 6720:a53006dc13cd.
Diffstat (limited to 'src/CallTip.cxx')
-rw-r--r--src/CallTip.cxx10
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