From 6ec693d598da1b2c7aaa4530644dc55a2f5ab8e1 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 23 Sep 2015 00:43:40 +0100 Subject: [PATCH] Cleanup compute_needed_size implementation --- src/ncurses_ui.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index e63c6bc1..cdcf5d50 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -721,17 +721,15 @@ void NCursesUI::menu_hide() static CharCoord compute_needed_size(StringView str) { - using Utf8Iterator = utf8::iterator; - CharCoord res{1,0}; CharCount line_len = 0; - for (Utf8Iterator begin{str.begin()}, end{str.end()}; - begin != end; ++begin) + for (auto it = str.begin(), end = str.end(); + it != end; it = utf8::next(it, end)) { - if (*begin == '\n') + if (*it == '\n') { // ignore last '\n', no need to show an empty line - if (begin+1 == end) + if (it+1 == end) break; res.column = max(res.column, line_len);