Skip to content

Call trap_GetCurrentCmdNumber only once per frame#2684

Merged
slipher merged 2 commits intoUnvanquished:masterfrom
slipher:cmdnum
May 16, 2023
Merged

Call trap_GetCurrentCmdNumber only once per frame#2684
slipher merged 2 commits intoUnvanquished:masterfrom
slipher:cmdnum

Conversation

@slipher
Copy link
Copy Markdown
Contributor

@slipher slipher commented May 8, 2023

No description provided.

@slipher
Copy link
Copy Markdown
Contributor Author

slipher commented May 8, 2023

I tested by replacing each access of cg.currentCmdNumber with the expression (cg.currentCmdNumber != trap_GetCurrentCmdNumber() ? (Sys::Drop("NTHNTHTNH"),0) : cg.currentCmdNumber).

@slipher
Copy link
Copy Markdown
Contributor Author

slipher commented May 8, 2023

Sadly I did not read #2660 first and created a duplicate version of one of the commits

Copy link
Copy Markdown
Member

@illwieckz illwieckz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven' tested the patch but it is very similar to one I wrote.

LGTM

@illwieckz
Copy link
Copy Markdown
Member

Sadly I did not read #2660 first and created a duplicate version of one of the commits

When I commit a modified version of a code someone else wrote I usually add a Co-authored-by: line to the commit:

@ghost
Copy link
Copy Markdown

ghost commented May 15, 2023

cgame is not my area, but from my little knowledge, the code seems fine. I'd appreciate it if we could have some informations about the risks.
The benefits of the trap_call() reduction is obviously performance improvement, but there must be risks around this too?

I know we're not using that much, but I also think the value should have a default value, C++11-style. Here, it might (I said, I don't know the cgame area, right) be un-init. And if I'm wrong, I might become true in the future.
I think we should strive for default values in the structs/classes as much as we can as they avoid many risks, in exchange (arguable) for small performance impacts

@illwieckz
Copy link
Copy Markdown
Member

This optimization is pretty safe. I doubt we can set a meaningful default value to this variable.

@ghost
Copy link
Copy Markdown

ghost commented May 15, 2023

I doubt we can set a meaningful default value to this variable.

@slipher
Copy link
Copy Markdown
Contributor Author

slipher commented May 15, 2023

When I commit a modified version of a code someone else wrote I usually add a Co-authored-by: line to the commit:

Well I didn't modify yours; I independently rediscovered it 😆

I know we're not using that much, but I also think the value should have a default value, C++11-style. Here, it might (I said, I don't know the cgame area, right) be un-init. And if I'm wrong, I might become true in the future.

As part of the cg global variable it is initialized to 0.

@slipher slipher merged commit fbd536c into Unvanquished:master May 16, 2023
@slipher slipher deleted the cmdnum branch May 16, 2023 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants