aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-02-20 18:18:08 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-02-20 18:18:08 -0800
commit7b873179adbfb0f0f1fcf9a1e746734f4ae6d38b (patch)
tree97eeb43a052b79e3f0290d2b163d8efbafb0b380 /reader.cpp
parentf1d923714a0d53f6d91ef6ba10dfa0360c1e7007 (diff)
Use swap instead of copying in reader_repaint_without_autosuggestion
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/reader.cpp b/reader.cpp
index 7c89a560..da367523 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -545,16 +545,14 @@ static void reader_repaint()
static void reader_repaint_without_autosuggestion()
{
- const wcstring saved_autosuggestion = data->autosuggestion;
-
- data->autosuggestion.clear();
+ // Swap in an empty autosuggestion, repaint, then swap it out
+ wcstring saved_autosuggestion;
+ data->autosuggestion.swap(saved_autosuggestion);
reader_repaint();
- data->autosuggestion = saved_autosuggestion;
+ data->autosuggestion.swap(saved_autosuggestion);
}
-/**
- Internal helper function for handling killing parts of text.
-*/
+/** Internal helper function for handling killing parts of text. */
static void reader_kill(size_t begin_idx, size_t length, int mode, int newv)
{
const wchar_t *begin = data->command_line.c_str() + begin_idx;
@@ -1753,7 +1751,8 @@ static bool handle_completions(const std::vector<completion_t> &comp)
is_quoted = (quote != L'\0');
/* Clear the autosuggestion from the old commandline before abandoning it (see #561) */
- reader_repaint_without_autosuggestion();
+ if (! data->autosuggestion.empty())
+ reader_repaint_without_autosuggestion();
write_loop(1, "\n", 1);