From 63fe6c65983a4cf2eba4995d03abd7e8a39c4a43 Mon Sep 17 00:00:00 2001 From: PeterN Date: Sat, 2 Mar 2019 08:06:02 +0000 Subject: [PATCH] Codechange: Make std::stack use std::vector container in string formatting/drawing. (#7305) This is a very minor performance increase which can add up during operations such as sorting. Performance impact my be platform/compiler dependent. --- src/gfx_layout.h | 3 ++- src/strings.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gfx_layout.h b/src/gfx_layout.h index f6fc3b5c71..94cbac073a 100644 --- a/src/gfx_layout.h +++ b/src/gfx_layout.h @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef WITH_ICU_LAYOUT #include "layout/ParagraphLayout.h" @@ -35,7 +36,7 @@ struct FontState { FontSize fontsize; ///< Current font size. TextColour cur_colour; ///< Current text colour. - std::stack colour_stack; ///< Stack of colours to assist with colour switching. + std::stack> colour_stack; ///< Stack of colours to assist with colour switching. FontState() : fontsize(FS_END), cur_colour(TC_INVALID) {} FontState(TextColour colour, FontSize fontsize) : fontsize(fontsize), cur_colour(colour) {} diff --git a/src/strings.cpp b/src/strings.cpp index 2cc3a23be2..a3ece9830e 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -791,7 +791,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg WChar b = '\0'; uint next_substr_case_index = 0; char *buf_start = buff; - std::stack str_stack; + std::stack> str_stack; str_stack.push(str_arg); for (;;) {