Replace some String temporaries with StringViews

This commit is contained in:
Maxime Coste 2015-04-27 16:39:51 +01:00
parent 720c54c759
commit 5bff742e0a
8 changed files with 9 additions and 9 deletions

View File

@ -138,7 +138,7 @@ Buffer* create_fifo_buffer(String name, int fd, bool scroll)
if (prevent_scrolling)
++pos;
buffer->insert(pos, String(data, data+count));
buffer->insert(pos, StringView(data, data+count));
if (count > 0 and prevent_scrolling)
{

View File

@ -28,7 +28,7 @@ static Face parse_face(StringView facedesc)
case 'b': res.attributes |= Attribute::Bold; break;
case 'B': res.attributes |= Attribute::Blink; break;
case 'd': res.attributes |= Attribute::Dim; break;
default: throw runtime_error("unknown face attribute '" + String(*attr_it) + "'");
default: throw runtime_error("unknown face attribute '" + StringView(*attr_it) + "'");
}
}
}

View File

@ -120,7 +120,7 @@ String read_fd(int fd)
if (size == -1 or size == 0)
break;
content += String(buf, buf + size);
content += StringView(buf, buf + size);
}
return content;
}

View File

@ -276,7 +276,7 @@ public:
}
catch (RegexError& err)
{
throw runtime_error(String("regex error: ") + err.what());
throw runtime_error(StringView{"regex error: "} + err.what());
}
}
@ -1121,7 +1121,7 @@ public:
}
catch (RegexError& err)
{
throw runtime_error(String("regex error: ") + err.what());
throw runtime_error(StringView{"regex error: "} + err.what());
}
}

View File

@ -519,7 +519,7 @@ int run_pipe(StringView session)
write_stderr("error while reading stdin\n");
return -1;
}
command += String{buf, buf + count};
command += StringView{buf, buf + count};
}
try
{

View File

@ -656,7 +656,7 @@ void use_selection_as_search_pattern(Context& context, NormalParams)
{
auto begin = utf8::make_iterator(buffer.iterator_at(sel.min()));
auto end = utf8::make_iterator(buffer.iterator_at(sel.max()))+1;
auto content = "\\Q" + String{begin.base(), end.base()} + "\\E";
auto content = "\\Q" + buffer.string(begin.base().coord(), end.base().coord()) + "\\E";
if (smart)
{
if (begin == buffer.begin() or (is_word(*begin) and not is_word(*(begin-1))))

View File

@ -8,7 +8,7 @@ namespace Kakoune
String option_to_string(const Regex& re)
{
const auto& str = re.str();
return String{str.begin(), str.end()};
return {str.begin(), str.end()};
}
void option_from_string(StringView str, Regex& re)

View File

@ -55,7 +55,7 @@ std::pair<String, int> ShellManager::eval(
size_t size = read(watcher.fd(), buffer, 1024);
if (size <= 0)
watcher.close_fd();
output += String(buffer, buffer+size);
output += StringView{buffer, buffer+size};
};
};