Have MetaProcessor::process take an llvm::StringRef. Remove unnecessary std::string -> const char* -> std::string conversions.

This commit is contained in:
Frederich Munch 2017-06-06 11:23:41 -04:00 committed by sftnight
parent 0ab04566ee
commit 38c757e36d
4 changed files with 11 additions and 12 deletions

View File

@ -114,7 +114,7 @@ namespace cling {
/// have in case of multi input mode.
///\returns -1 if quit was requiested.
///
int process(const char* input_line,
int process(llvm::StringRef input_line,
Interpreter::CompilationResult& compRes,
cling::Value* result = nullptr,
bool disableValuePrinting = false);

View File

@ -291,7 +291,7 @@ namespace cling {
MetaProcessor::~MetaProcessor() {
}
int MetaProcessor::process(const char* input_text,
int MetaProcessor::process(llvm::StringRef input_line,
Interpreter::CompilationResult& compRes,
Value* result,
bool disableValuePrinting /* = false */) {
@ -302,14 +302,13 @@ namespace cling {
if (expectedIndent)
compRes = Interpreter::kMoreInputExpected;
if (!input_text || !input_text[0]) {
// nullptr / empty string, nothing to do.
return expectedIndent;
}
std::string input_line(input_text);
if (input_line == "\n") { // just a blank line, nothing to do.
if (input_line.empty() ||
(input_line.size() == 1 && input_line.front() == '\n')) {
// just a blank line, nothing to do.
return expectedIndent;
}
// Check for and handle meta commands.
m_MetaParser->enterNewInputLine(input_line);
MetaSema::ActionResult actionResult = MetaSema::AR_Success;
@ -477,7 +476,7 @@ namespace cling {
std::string line;
std::stringstream ss(content);
while (std::getline(ss, line, '\n')) {
rslt = process(line.c_str(), ret, result);
rslt = process(line, ret, result);
if (ret == Interpreter::kFailure)
break;
}

View File

@ -95,7 +95,7 @@ namespace cling {
}
cling::Interpreter::CompilationResult compRes;
const int indent = m_MetaProcessor->process(Line.c_str(), compRes);
const int indent = m_MetaProcessor->process(Line, compRes);
// Quit requested?
if (indent < 0)

View File

@ -120,14 +120,14 @@ int main( int argc, char **argv ) {
// TODO: Check whether the filename specified after #! is the current
// executable.
while (std::getline(File, Line)) {
Ui.getMetaProcessor()->process(Line.c_str(), Result, 0);
Ui.getMetaProcessor()->process(Line, Result, 0);
}
continue;
}
Cmd += ".x ";
}
Cmd += Input;
Ui.getMetaProcessor()->process(Cmd.c_str(), Result, 0);
Ui.getMetaProcessor()->process(Cmd, Result, 0);
}
}
else {