From 05b79921a9649933884e48c457c26d6f1e10c870 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 10 May 2014 16:25:07 +0100 Subject: [PATCH] Minor code cleanups in buffer.{cc,hh} --- src/buffer.cc | 13 +++---------- src/buffer.hh | 18 +++++++++--------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/buffer.cc b/src/buffer.cc index d16d53a3..dbdd6247 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -178,23 +178,16 @@ struct Buffer::Modification { enum Type { Insert, Erase }; - Type type; + Type type; ByteCoord coord; - String content; + String content; Modification(Type type, ByteCoord coord, String content) : type(type), coord(coord), content(std::move(content)) {} Modification inverse() const { - Type inverse_type = Insert; - switch (type) - { - case Insert: inverse_type = Erase; break; - case Erase: inverse_type = Insert; break; - default: kak_assert(false); - } - return {inverse_type, coord, content}; + return {type == Insert ? Erase : Insert, coord, content}; } }; diff --git a/src/buffer.hh b/src/buffer.hh index ece9fedb..ff09528e 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -117,20 +117,20 @@ public: char byte_at(ByteCoord c) const; ByteCount offset(ByteCoord c) const; ByteCount distance(ByteCoord begin, ByteCoord end) const; - ByteCoord advance(ByteCoord coord, ByteCount count) const; - ByteCoord next(ByteCoord coord) const; - ByteCoord prev(ByteCoord coord) const; + ByteCoord advance(ByteCoord coord, ByteCount count) const; + ByteCoord next(ByteCoord coord) const; + ByteCoord prev(ByteCoord coord) const; - ByteCoord char_next(ByteCoord coord) const; - ByteCoord char_prev(ByteCoord coord) const; + ByteCoord char_next(ByteCoord coord) const; + ByteCoord char_prev(ByteCoord coord) const; - ByteCoord back_coord() const; - ByteCoord end_coord() const; + ByteCoord back_coord() const; + ByteCoord end_coord() const; bool is_valid(ByteCoord c) const; bool is_end(ByteCoord c) const; - ByteCoord last_modification_coord() const; + ByteCoord last_modification_coord() const; BufferIterator begin() const; BufferIterator end() const; @@ -144,7 +144,7 @@ public: BufferIterator iterator_at(ByteCoord coord) const; // returns nearest valid coordinates from given ones - ByteCoord clamp(ByteCoord coord) const; + ByteCoord clamp(ByteCoord coord) const; ByteCoord offset_coord(ByteCoord coord, CharCount offset); ByteCoord offset_coord(ByteCoord coord, LineCount offset);