From 76f55f5256f15109c7b245ca398e4dde3f5223c6 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 4 Jun 2013 13:41:30 +0200 Subject: [PATCH] remove useless iterator_at calls --- src/commands.cc | 2 +- src/editor.hh | 2 +- src/normal.cc | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index a9c29acd..a2eb08d3 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -129,7 +129,7 @@ void edit(const CommandParameters& params, Context& context) int column = param_count > 2 ? std::max(0, str_to_int(parser[2]) - 1) : 0; - context.editor().select(context.buffer().iterator_at({ line, column })); + context.editor().select(context.buffer().clamp({ line, column })); if (context.has_window()) context.window().center_selection(); } diff --git a/src/editor.hh b/src/editor.hh index 7bd5b67f..b527d513 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -62,7 +62,7 @@ public: void keep_selection(int index); void remove_selection(int index); void select(const BufferCoord& c, SelectMode mode = SelectMode::Replace) - { auto it = m_buffer->iterator_at(c); select(Selection{ it, it }, mode); } + { select(Selection{ c, c }, mode); } void select(const Selection& sel, SelectMode mode = SelectMode::Replace); void select(const Selector& selector, diff --git a/src/normal.cc b/src/normal.cc index bd3bf3c7..fc60a0f3 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -80,7 +80,7 @@ void goto_commands(Context& context) case 'g': case 'k': context.push_jump(); - editor.select(editor.buffer().begin(), mode); + editor.select(BufferCoord{0,0}, mode); break; case 'l': editor.select(select_to_eol, mode); @@ -91,8 +91,7 @@ void goto_commands(Context& context) case 'j': { context.push_jump(); - const Buffer& buf = editor.buffer(); - editor.select(buf.iterator_at(buf.line_count() - 1), mode); + editor.select(editor.buffer().line_count() - 1, mode); break; } case 'e': @@ -103,7 +102,7 @@ void goto_commands(Context& context) if (context.has_window()) { auto line = context.window().position().line; - editor.select(editor.buffer().iterator_at(line), mode); + editor.select(line, mode); } break; case 'b': @@ -111,7 +110,7 @@ void goto_commands(Context& context) { auto& window = context.window(); auto line = window.position().line + window.dimensions().line - 1; - editor.select(editor.buffer().iterator_at(line), mode); + editor.select(line, mode); } break; case 'c': @@ -119,7 +118,7 @@ void goto_commands(Context& context) { auto& window = context.window(); auto line = window.position().line + window.dimensions().line / 2; - editor.select(editor.buffer().iterator_at(line), mode); + editor.select(line, mode); } break; case 'a':