fix: optimization: PVS-Studio warning V831
Replaced 'at()' method with 'operator[]' to improve performance. The 'at()' method performs bounds checking, which can introduce overhead. Using 'operator[]' bypasses this check and can improve performance when you are certain that the index is within bounds. Reported by: PVS-Studio Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
@@ -145,7 +145,7 @@ uint Label::getLineByYOffset(int offset) const {
|
||||
|
||||
uint Label::getLineByTextIndex(size_t index) const {
|
||||
for (size_t i = 0; i < cache.lines.size(); i++) {
|
||||
if (cache.lines.at(i).offset > index) {
|
||||
if (cache.lines[i].offset > index) {
|
||||
return i-1;
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ void Label::draw(const DrawContext* pctx, Assets* assets) {
|
||||
|
||||
if (multiline) {
|
||||
for (size_t i = 0; i < cache.lines.size(); i++) {
|
||||
auto& line = cache.lines.at(i);
|
||||
auto& line = cache.lines[i];
|
||||
size_t offset = line.offset;
|
||||
std::wstring_view view(text.c_str()+offset, text.length()-offset);
|
||||
if (i < cache.lines.size()-1) {
|
||||
|
||||
Reference in New Issue
Block a user