Efficiency fix for the formatting code
This commit is contained in:
parent
2f083b8bdb
commit
cae49a2998
1 changed files with 12 additions and 9 deletions
|
|
@ -262,18 +262,21 @@ void format_t::format(std::ostream& out_str, scope_t& scope)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
unistring temp(out.str());
|
if (elem->max_width > 0 || elem->min_width > 0) {
|
||||||
|
unistring temp(out.str());
|
||||||
|
|
||||||
string result;
|
string result;
|
||||||
if (elem->max_width > 0 && elem->max_width < temp.length()) {
|
if (elem->max_width > 0 && elem->max_width < temp.length()) {
|
||||||
result = truncate(temp, elem->max_width);
|
result = truncate(temp, elem->max_width);
|
||||||
|
} else {
|
||||||
|
result = temp.extract();
|
||||||
|
for (int i = 0; i < (int)elem->min_width - (int)temp.length(); i++)
|
||||||
|
result += " ";
|
||||||
|
}
|
||||||
|
out_str << result;
|
||||||
} else {
|
} else {
|
||||||
result = temp.extract();
|
out_str << out.str();
|
||||||
for (int i = 0; i < (int)elem->min_width - (int)temp.length(); i++)
|
|
||||||
result += " ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out_str << result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue