From 9ec10daf6991a6135cc03ec9c9a8fae5d670dcf4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 2 Oct 2012 14:08:09 +0200 Subject: move clamp to utils.hh --- src/buffer.cc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/buffer.cc') diff --git a/src/buffer.cc b/src/buffer.cc index 5b868cec..1eac7bcc 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -11,16 +11,6 @@ namespace Kakoune { -template -T clamp(T min, T max, T val) -{ - if (val < min) - return min; - if (val > max) - return max; - return val; -} - Buffer::Buffer(String name, Type type, String initial_content) : m_name(std::move(name)), m_type(type), @@ -83,9 +73,9 @@ BufferCoord Buffer::clamp(const BufferCoord& line_and_column, return BufferCoord(); BufferCoord result(line_and_column.line, line_and_column.column); - result.line = Kakoune::clamp(0_line, line_count() - 1, result.line); + result.line = Kakoune::clamp(result.line, 0_line, line_count() - 1); CharCount max_col = std::max(0_char, line_length(result.line) - (avoid_eol ? 2 : 1)); - result.column = Kakoune::clamp(0_char, max_col, result.column); + result.column = Kakoune::clamp(result.column, 0_char, max_col); return result; } -- cgit v1.2.3