Issue found with PVS-Studio:

Many instances of a function or expression being used repeatedly, which can lower performance.

Fixed it in these cases by creating on local var, reference or pointer that's used instead.
This commit is contained in:
Areloch 2015-07-13 22:51:17 -05:00
parent ec63398042
commit 2002d74b78
38 changed files with 465 additions and 371 deletions

View file

@ -465,6 +465,8 @@ bool GuiControl::defaultTooltipRender( const Point2I &hoverPos, const Point2I &c
GFont *font = mTooltipProfile->mFont;
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
// Support for multi-line tooltip text...
Vector<U32> startLineOffsets, lineLengths;
@ -521,12 +523,12 @@ bool GuiControl::defaultTooltipRender( const Point2I &hoverPos, const Point2I &c
GFX->setClipRect( rect );
// Draw Filler bit, then border on top of that
GFX->getDrawUtil()->drawRectFill( rect, mTooltipProfile->mFillColor );
GFX->getDrawUtil()->drawRect( rect, mTooltipProfile->mBorderColor );
drawUtil->drawRectFill( rect, mTooltipProfile->mFillColor );
drawUtil->drawRect( rect, mTooltipProfile->mBorderColor );
// Draw the text centered in the tool tip box...
GFX->getDrawUtil()->setBitmapModulation( mTooltipProfile->mFontColor );
drawUtil->setBitmapModulation( mTooltipProfile->mFontColor );
for ( U32 i = 0; i < lineLengths.size(); i++ )
{
@ -534,7 +536,7 @@ bool GuiControl::defaultTooltipRender( const Point2I &hoverPos, const Point2I &c
const UTF8 *line = renderTip.c_str() + startLineOffsets[i];
U32 lineLen = lineLengths[i];
GFX->getDrawUtil()->drawTextN( font, start + offset, line, lineLen, mProfile->mFontColors );
drawUtil->drawTextN( font, start + offset, line, lineLen, mProfile->mFontColors );
}
GFX->setClipRect( oldClip );

View file

@ -41,15 +41,17 @@ void renderRaisedBox( const RectI &bounds, GuiControlProfile *profile )
S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1;
S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1;
GFX->getDrawUtil()->drawRectFill( bounds, profile->mFillColor);
GFX->getDrawUtil()->drawLine(l, t, l, b - 1, colorWhite);
GFX->getDrawUtil()->drawLine(l, t, r - 1, t, colorWhite);
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
GFX->getDrawUtil()->drawLine(l, b, r, b, colorBlack);
GFX->getDrawUtil()->drawLine(r, b - 1, r, t, colorBlack);
drawUtil->drawRectFill( bounds, profile->mFillColor);
drawUtil->drawLine(l, t, l, b - 1, colorWhite);
drawUtil->drawLine(l, t, r - 1, t, colorWhite);
GFX->getDrawUtil()->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(r - 1, b - 2, r - 1, t + 1, profile->mBorderColor);
drawUtil->drawLine(l, b, r, b, colorBlack);
drawUtil->drawLine(r, b - 1, r, t, colorBlack);
drawUtil->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor);
drawUtil->drawLine(r - 1, b - 2, r - 1, t + 1, profile->mBorderColor);
}
void renderSlightlyRaisedBox( const RectI &bounds, GuiControlProfile *profile )
@ -70,16 +72,18 @@ void renderLoweredBox( const RectI &bounds, GuiControlProfile *profile )
S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1;
S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1;
GFX->getDrawUtil()->drawRectFill( bounds, profile->mFillColor);
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
GFX->getDrawUtil()->drawLine(l, b, r, b, colorWhite);
GFX->getDrawUtil()->drawLine(r, b - 1, r, t, colorWhite);
drawUtil->drawRectFill( bounds, profile->mFillColor);
GFX->getDrawUtil()->drawLine(l, t, r - 1, t, colorBlack);
GFX->getDrawUtil()->drawLine(l, t + 1, l, b - 1, colorBlack);
drawUtil->drawLine(l, b, r, b, colorWhite);
drawUtil->drawLine(r, b - 1, r, t, colorWhite);
GFX->getDrawUtil()->drawLine(l + 1, t + 1, r - 2, t + 1, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(l + 1, t + 2, l + 1, b - 2, profile->mBorderColor);
drawUtil->drawLine(l, t, r - 1, t, colorBlack);
drawUtil->drawLine(l, t + 1, l, b - 1, colorBlack);
drawUtil->drawLine(l + 1, t + 1, r - 2, t + 1, profile->mBorderColor);
drawUtil->drawLine(l + 1, t + 2, l + 1, b - 2, profile->mBorderColor);
}
void renderSlightlyLoweredBox( const RectI &bounds, GuiControlProfile *profile )
@ -87,11 +91,13 @@ void renderSlightlyLoweredBox( const RectI &bounds, GuiControlProfile *profile )
S32 l = bounds.point.x + 1, r = bounds.point.x + bounds.extent.x - 1;
S32 t = bounds.point.y + 1, b = bounds.point.y + bounds.extent.y - 1;
GFX->getDrawUtil()->drawRectFill( bounds, profile->mFillColor);
GFX->getDrawUtil()->drawLine(l, b, r, b, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(r, t, r, b - 1, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(l, t, l, b - 1, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(l + 1, t, r - 1, t, profile->mBorderColor);
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
drawUtil->drawRectFill( bounds, profile->mFillColor);
drawUtil->drawLine(l, b, r, b, profile->mBorderColor);
drawUtil->drawLine(r, t, r, b - 1, profile->mBorderColor);
drawUtil->drawLine(l, t, l, b - 1, profile->mBorderColor);
drawUtil->drawLine(l + 1, t, r - 1, t, profile->mBorderColor);
}
void renderBorder( const RectI &bounds, GuiControlProfile *profile )