Changeset - r23375:ca293b1be7a0
[Not reviewed]
master
0 2 0
PeterN - 6 years ago 2019-03-02 08:06:02
peter@fuzzle.org
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.
2 files changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/gfx_layout.h
Show inline comments
 
@@ -16,12 +16,13 @@
 
#include "gfx_func.h"
 
#include "core/smallmap_type.hpp"
 

	
 
#include <map>
 
#include <string>
 
#include <stack>
 
#include <vector>
 

	
 
#ifdef WITH_ICU_LAYOUT
 
#include "layout/ParagraphLayout.h"
 
#define ICU_FONTINSTANCE : public icu::LEFontInstance
 
#else /* WITH_ICU_LAYOUT */
 
#define ICU_FONTINSTANCE
 
@@ -32,13 +33,13 @@
 
 * of the same text, e.g. on line breaks.
 
 */
 
struct FontState {
 
	FontSize fontsize;       ///< Current font size.
 
	TextColour cur_colour;   ///< Current text colour.
 

	
 
	std::stack<TextColour> colour_stack; ///< Stack of colours to assist with colour switching.
 
	std::stack<TextColour, std::vector<TextColour>> 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) {}
 

	
 
	/**
 
	 * Switch to new colour \a c.
src/strings.cpp
Show inline comments
 
@@ -788,13 +788,13 @@ static char *FormatString(char *buff, co
 
		/* We have to restore the original offset here to to read the correct values. */
 
		args->offset = orig_offset;
 
	}
 
	WChar b = '\0';
 
	uint next_substr_case_index = 0;
 
	char *buf_start = buff;
 
	std::stack<const char *> str_stack;
 
	std::stack<const char *, std::vector<const char *>> str_stack;
 
	str_stack.push(str_arg);
 

	
 
	for (;;) {
 
		while (!str_stack.empty() && (b = Utf8Consume(&str_stack.top())) == '\0') {
 
			str_stack.pop();
 
		}
0 comments (0 inline, 0 general)