summaryrefslogtreecommitdiffstats
path: root/Source/cmDependsJavaParserHelper.cxx
diff options
context:
space:
mode:
authorArtur Ryt <artur.ryt@gmail.com>2019-03-30 15:11:21 (GMT)
committerArtur Ryt <artur.ryt@gmail.com>2019-03-30 15:15:05 (GMT)
commit2d66567dca2a5a80e41493ec0a9d6d86f7d955f5 (patch)
tree84468e248f456f65c75a99033ba8073e48ea0f5b /Source/cmDependsJavaParserHelper.cxx
parent5bdee3786359b6560eb9ee1d6fab8664feb90db4 (diff)
downloadCMake-2d66567dca2a5a80e41493ec0a9d6d86f7d955f5.zip
CMake-2d66567dca2a5a80e41493ec0a9d6d86f7d955f5.tar.gz
CMake-2d66567dca2a5a80e41493ec0a9d6d86f7d955f5.tar.bz2
Modernize: Prefer .substr in place of .c_str() + int
A lot of temporary/local strings were created out of C-strings substr can utilize current string size, so in theory be a little more efficient.
Diffstat (limited to 'Source/cmDependsJavaParserHelper.cxx')
-rw-r--r--Source/cmDependsJavaParserHelper.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index 792db48..12d875d 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -5,6 +5,7 @@
#include "cmDependsJavaLexer.h"
#include "cmSystemTools.h"
+#include "cm_string_view.hxx"
#include "cmsys/FStream.hxx"
#include <iostream>
#include <stdio.h>
@@ -298,14 +299,10 @@ void cmDependsJavaParserHelper::Error(const char* str)
unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
fprintf(stderr, "JPError: %s (%lu / Line: %d)\n", str, pos,
this->CurrentLine);
- int cc;
- std::cerr << "String: [";
- for (cc = 0;
- cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
- cc++) {
- std::cerr << *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
- }
- std::cerr << "]" << std::endl;
+ std::cerr << "String: ["
+ << cm::string_view{ this->InputBuffer }.substr(
+ this->InputBufferPos, 30)
+ << "]" << std::endl;
}
void cmDependsJavaParserHelper::UpdateCombine(const char* str1,