8000 perf(heightmap): Optimize repeated calls to getXWithOrigin(), getYWithOrigin() in HeightMapRenderObjClass::updateVB by xezon · Pull Request #2102 · TheSuperHackers/GeneralsGameCode · GitHub
[go: up one dir, main page]

Skip to content

perf(heightmap): Optimize repeated calls to getXWithOrigin(), getYWithOrigin() in HeightMapRenderObjClass::updateVB#2102

Merged
xezon merged 1 commit intoTheSuperHackers:mainfrom
xezon:xezon/optimize-heightmap-updatevb
Jan 14, 2026
Merged

perf(heightmap): Optimize repeated calls to getXWithOrigin(), getYWithOrigin() in HeightMapRenderObjClass::updateVB#2102
xezon merged 1 commit intoTheSuperHackers:mainfrom
xezon:xezon/optimize-heightmap-updatevb

Conversation

@xezon
Copy link
@xezon xezon commented Jan 13, 2026

HeightMapRenderObjClass::updateVB is a heavy function for heightmap update performance. It does call getXWithOrigin and getYWithOrigin, which is unnecessary and not cheap:

Int HeightMapRenderObjClass::getXWithOrigin(Int x)
{
	x -= m_originX;
	if (x<0) x+= m_x-1;
	if (x>= m_x-1) x-=m_x-1;
#ifdef RTS_DEBUG
	DEBUG_ASSERTCRASH (x>=0, ("X out of range."));
	DEBUG_ASSERTCRASH (x<m_x-1, ("X out of range."));
#endif
	if (x<0) x = 0;
	if (x>= m_x-1) x=m_x-1;
	return x;
}

I did not measure performance impact but it should be a bit and very safe. Essentially this is just a code refactor for performance gains.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Pull Request was approved Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Performance Is a performance concern ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0