diff --git a/src/buffer.cc b/src/buffer.cc index c8853708..770be530 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -86,7 +86,7 @@ bool Buffer::set_name(String name) return false; } -BufferIterator Buffer::iterator_at(const BufferCoord& coord) const +BufferIterator Buffer::iterator_at(BufferCoord coord) const { return is_end(coord) ? end() : BufferIterator(*this, clamp(coord)); } @@ -126,7 +126,7 @@ LineCount Buffer::line_count() const return LineCount(m_lines.size()); } -String Buffer::string(const BufferCoord& begin, const BufferCoord& end) const +String Buffer::string(BufferCoord begin, BufferCoord end) const { String res; for (auto line = begin.line; line <= end.line and line < line_count(); ++line) @@ -187,7 +187,7 @@ class UndoGroupOptimizer return coord; } - static ByteCount count_byte_to(BufferCoord pos, const BufferCoord& endpos, const String& str) + static ByteCount count_byte_to(BufferCoord pos, BufferCoord endpos, const String& str) { ByteCount count = 0; for (auto it = str.begin(); it != str.end() and pos != endpos; ++it) @@ -417,7 +417,7 @@ void Buffer::check_invariant() const #endif } -BufferCoord Buffer::do_insert(const BufferCoord& pos, const String& content) +BufferCoord Buffer::do_insert(BufferCoord pos, const String& content) { kak_assert(is_valid(pos)); @@ -497,7 +497,7 @@ BufferCoord Buffer::do_insert(const BufferCoord& pos, const String& content) return begin; } -BufferCoord Buffer::do_erase(const BufferCoord& begin, const BufferCoord& end) +BufferCoord Buffer::do_erase(BufferCoord begin, BufferCoord end) { kak_assert(is_valid(begin)); kak_assert(is_valid(end)); @@ -531,7 +531,7 @@ BufferCoord Buffer::do_erase(const BufferCoord& begin, const BufferCoord& end) void Buffer::apply_modification(const Modification& modification) { const String& content = modification.content; - const BufferCoord& coord = modification.coord; + BufferCoord coord = modification.coord; kak_assert(is_valid(coord)); // in modifications, end coords should be {line_count(), 0} @@ -678,31 +678,31 @@ BufferCoord Buffer::char_prev(BufferCoord coord) const return coord; } -ByteCount Buffer::distance(const BufferCoord& begin, const BufferCoord& end) const +ByteCount Buffer::distance(BufferCoord begin, BufferCoord end) const { return offset(end) - offset(begin); } -ByteCount Buffer::offset(const BufferCoord& c) const +ByteCount Buffer::offset(BufferCoord c) const { if (c.line == line_count()) return m_lines.back().start + m_lines.back().length(); return m_lines[c.line].start + c.column; } -bool Buffer::is_valid(const BufferCoord& c) const +bool Buffer::is_valid(BufferCoord c) const { return (c.line < line_count() and c.column < m_lines[c.line].length()) or (c.line == line_count() - 1 and c.column == m_lines.back().length()) or (c.line == line_count() and c.column == 0); } -bool Buffer::is_end(const BufferCoord& c) const +bool Buffer::is_end(BufferCoord c) const { return c >= BufferCoord{line_count() - 1, m_lines.back().length()}; } -char Buffer::byte_at(const BufferCoord& c) const +char Buffer::byte_at(BufferCoord c) const { kak_assert(c.line < line_count() and c.column < m_lines[c.line].length()); return m_lines[c.line].content[c.column]; diff --git a/src/buffer.hh b/src/buffer.hh index 61b9179e..0cc20fd0 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -69,8 +69,8 @@ private: class BufferChangeListener { public: - virtual void on_insert(const Buffer& buffer, const BufferCoord& begin, const BufferCoord& end) = 0; - virtual void on_erase(const Buffer& buffer, const BufferCoord& begin, const BufferCoord& end) = 0; + virtual void on_insert(const Buffer& buffer, BufferCoord begin, BufferCoord end) = 0; + virtual void on_erase(const Buffer& buffer, BufferCoord begin, BufferCoord end) = 0; }; // A Buffer is a in-memory representation of a file @@ -109,11 +109,11 @@ public: bool undo(); bool redo(); - String string(const BufferCoord& begin, const BufferCoord& end) const; + String string(BufferCoord begin, BufferCoord end) const; - char byte_at(const BufferCoord& c) const; - ByteCount offset(const BufferCoord& c) const; - ByteCount distance(const BufferCoord& begin, const BufferCoord& end) const; + char byte_at(BufferCoord c) const; + ByteCount offset(BufferCoord c) const; + ByteCount distance(BufferCoord begin, BufferCoord end) const; BufferCoord advance(BufferCoord coord, ByteCount count) const; BufferCoord next(BufferCoord coord) const; BufferCoord prev(BufferCoord coord) const; @@ -124,8 +124,8 @@ public: BufferCoord back_coord() const { return { line_count() - 1, m_lines.back().length() - 1 }; } BufferCoord end_coord() const { return { line_count() - 1, m_lines.back().length() }; } - bool is_valid(const BufferCoord& c) const; - bool is_end(const BufferCoord& c) const; + bool is_valid(BufferCoord c) const; + bool is_end(BufferCoord c) const; BufferIterator begin() const; BufferIterator end() const; @@ -136,7 +136,7 @@ public: { return m_lines[line].content; } // returns an iterator at given coordinates. clamp line_and_column - BufferIterator iterator_at(const BufferCoord& coord) const; + BufferIterator iterator_at(BufferCoord coord) const; // returns nearest valid coordinates from given ones BufferCoord clamp(BufferCoord coord) const; @@ -177,8 +177,8 @@ private: }; LineList m_lines; - BufferCoord do_insert(const BufferCoord& pos, const String& content); - BufferCoord do_erase(const BufferCoord& begin, const BufferCoord& end); + BufferCoord do_insert(BufferCoord pos, const String& content); + BufferCoord do_erase(BufferCoord begin, BufferCoord end); String m_name; Flags m_flags; diff --git a/src/dynamic_selection_list.cc b/src/dynamic_selection_list.cc index dfc78436..92a95d1c 100644 --- a/src/dynamic_selection_list.cc +++ b/src/dynamic_selection_list.cc @@ -36,12 +36,12 @@ void DynamicSelectionList::check_invariant() const #endif } -void DynamicSelectionList::on_insert(const Buffer& buffer, const BufferCoord& begin, const BufferCoord& end) +void DynamicSelectionList::on_insert(const Buffer& buffer, BufferCoord begin, BufferCoord end) { update_insert(buffer, begin, end); } -void DynamicSelectionList::on_erase(const Buffer& buffer, const BufferCoord& begin, const BufferCoord& end) +void DynamicSelectionList::on_erase(const Buffer& buffer, BufferCoord begin, BufferCoord end) { update_erase(buffer, begin, end); } diff --git a/src/dynamic_selection_list.hh b/src/dynamic_selection_list.hh index 7f8da0f0..fc90dcfd 100644 --- a/src/dynamic_selection_list.hh +++ b/src/dynamic_selection_list.hh @@ -19,8 +19,8 @@ public: void check_invariant() const; private: - void on_insert(const Buffer& buffer, const BufferCoord& begin, const BufferCoord& end) override; - void on_erase(const Buffer& buffer, const BufferCoord& begin, const BufferCoord& end) override; + void on_insert(const Buffer& buffer, BufferCoord begin, BufferCoord end) override; + void on_erase(const Buffer& buffer, BufferCoord begin, BufferCoord end) override; }; } diff --git a/src/editor.cc b/src/editor.cc index 13253ae2..eed0fbe2 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -168,7 +168,7 @@ void sort_and_merge_overlapping(SelectionList& selections, size_t& main_selectio merge_overlapping(selections, main_selection, overlaps); } -BufferCoord Editor::offset_coord(const BufferCoord& coord, CharCount offset) +BufferCoord Editor::offset_coord(BufferCoord coord, CharCount offset) { auto& line = buffer()[coord.line]; auto character = std::max(0_char, std::min(line.char_count_to(coord.column) + offset, @@ -189,7 +189,7 @@ void Editor::move_selections(CharCount offset, SelectMode mode) sort_and_merge_overlapping(m_selections, m_main_sel); } -BufferCoord Editor::offset_coord(const BufferCoord& coord, LineCount offset) +BufferCoord Editor::offset_coord(BufferCoord coord, LineCount offset) { auto character = (*m_buffer)[coord.line].char_count_to(coord.column); auto line = clamp(coord.line + offset, 0_line, m_buffer->line_count()-1); @@ -364,21 +364,21 @@ public: ModifiedRangesListener(Buffer& buffer) : BufferChangeListener_AutoRegister(buffer) {} - void on_insert(const Buffer& buffer, const BufferCoord& begin, const BufferCoord& end) + void on_insert(const Buffer& buffer, BufferCoord begin, BufferCoord end) { m_ranges.update_insert(buffer, begin, end); auto it = std::upper_bound(m_ranges.begin(), m_ranges.end(), begin, - [](const BufferCoord& c, const Selection& sel) + [](BufferCoord c, const Selection& sel) { return c < sel.min(); }); m_ranges.emplace(it, begin, buffer.char_prev(end)); } - void on_erase(const Buffer& buffer, const BufferCoord& begin, const BufferCoord& end) + void on_erase(const Buffer& buffer, BufferCoord begin, BufferCoord end) { m_ranges.update_erase(buffer, begin, end); auto pos = std::min(begin, buffer.back_coord()); auto it = std::upper_bound(m_ranges.begin(), m_ranges.end(), pos, - [](const BufferCoord& c, const Selection& sel) + [](BufferCoord c, const Selection& sel) { return c < sel.min(); }); m_ranges.emplace(it, pos, pos); } diff --git a/src/editor.hh b/src/editor.hh index 95ddd2b1..bf70af70 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -61,7 +61,7 @@ public: void flip_selections(); void keep_selection(int index); void remove_selection(int index); - void select(const BufferCoord& c, SelectMode mode = SelectMode::Replace) + void select(BufferCoord c, SelectMode mode = SelectMode::Replace) { select(Selection{ buffer().clamp(c) }, mode); } void select(const Selection& sel, SelectMode mode = SelectMode::Replace); @@ -91,8 +91,8 @@ private: void begin_edition(); void end_edition(); - virtual BufferCoord offset_coord(const BufferCoord& coord, LineCount move); - virtual BufferCoord offset_coord(const BufferCoord& coord, CharCount move); + virtual BufferCoord offset_coord(BufferCoord coord, LineCount move); + virtual BufferCoord offset_coord(BufferCoord coord, CharCount move); int m_edition_level; diff --git a/src/highlighters.cc b/src/highlighters.cc index 1288f08f..940d4025 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -386,7 +386,7 @@ private: m_option->get>(); } - void on_insert(const Buffer&, const BufferCoord& begin, const BufferCoord& end) override + void on_insert(const Buffer&, BufferCoord begin, BufferCoord end) override { LineCount new_lines = end.line - begin.line; if (new_lines == 0) @@ -401,7 +401,7 @@ private: m_option->set(lines); } - void on_erase(const Buffer&, const BufferCoord& begin, const BufferCoord& end) override + void on_erase(const Buffer&, BufferCoord begin, BufferCoord end) override { LineCount removed_lines = end.line - begin.line; if (removed_lines == 0) diff --git a/src/input_handler.cc b/src/input_handler.cc index 1f947b66..997c6e96 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -497,7 +497,7 @@ struct BufferCompletion }; static BufferCompletion complete_word(const Buffer& buffer, - const BufferCoord& cursor_pos, + BufferCoord cursor_pos, bool other_buffers) { auto pos = buffer.iterator_at(cursor_pos); @@ -545,7 +545,7 @@ static BufferCompletion complete_word(const Buffer& buffer, } static BufferCompletion complete_opt(const Buffer& buffer, - const BufferCoord& cursor_pos, + BufferCoord cursor_pos, OptionManager& options) { using StringList = std::vector; diff --git a/src/line_and_column.hh b/src/line_and_column.hh index 76d70a21..27ed61f0 100644 --- a/src/line_and_column.hh +++ b/src/line_and_column.hh @@ -13,60 +13,60 @@ struct LineAndColumn constexpr LineAndColumn(LineType line = 0, ColumnType column = 0) : line(line), column(column) {} - constexpr EffectiveType operator+(const EffectiveType& other) const + constexpr EffectiveType operator+(EffectiveType other) const { return EffectiveType(line + other.line, column + other.column); } - EffectiveType& operator+=(const EffectiveType& other) + EffectiveType& operator+=(EffectiveType other) { line += other.line; column += other.column; return *static_cast(this); } - constexpr EffectiveType operator-(const EffectiveType& other) const + constexpr EffectiveType operator-(EffectiveType other) const { return EffectiveType(line - other.line, column - other.column); } - EffectiveType& operator-=(const EffectiveType& other) + EffectiveType& operator-=(EffectiveType other) { line -= other.line; column -= other.column; return *static_cast(this); } - constexpr bool operator< (const EffectiveType& other) const + constexpr bool operator< (EffectiveType other) const { return (line != other.line) ? line < other.line : column < other.column; } - constexpr bool operator<= (const EffectiveType& other) const + constexpr bool operator<= (EffectiveType other) const { return (line != other.line) ? line < other.line : column <= other.column; } - constexpr bool operator> (const EffectiveType& other) const + constexpr bool operator> (EffectiveType other) const { return (line != other.line) ? line > other.line : column > other.column; } - constexpr bool operator>= (const EffectiveType& other) const + constexpr bool operator>= (EffectiveType other) const { return (line != other.line) ? line > other.line : column >= other.column; } - constexpr bool operator== (const EffectiveType& other) const + constexpr bool operator== (EffectiveType other) const { return line == other.line and column == other.column; } - constexpr bool operator!= (const EffectiveType& other) const + constexpr bool operator!= (EffectiveType other) const { return line != other.line or column != other.column; } diff --git a/src/ncurses.cc b/src/ncurses.cc index 0f084da0..80c3dcb0 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -510,8 +510,8 @@ static DisplayCoord compute_needed_size(const String& str) return res; } -static DisplayCoord compute_pos(const DisplayCoord& anchor, - const DisplayCoord& size, +static DisplayCoord compute_pos(DisplayCoord anchor, + DisplayCoord size, WINDOW* opt_window_to_avoid = nullptr) { DisplayCoord scrsize = window_size(stdscr); diff --git a/src/normal.cc b/src/normal.cc index f1e0cac2..50912251 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -723,7 +723,7 @@ void align(Context& context) { auto& selections = context.editor().selections(); auto& buffer = context.buffer(); - auto get_column = [&buffer](const BufferCoord& coord) + auto get_column = [&buffer](BufferCoord coord) { return buffer[coord.line].char_count_to(coord.column); }; CharCount max_col = 0; diff --git a/src/selection.cc b/src/selection.cc index f7360e7f..a8ab889c 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -19,10 +19,10 @@ namespace template