Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass point by value #2461

Merged
merged 1 commit into from
Mar 25, 2023
Merged

Conversation

scarf005
Copy link
Member

@scarf005 scarf005 commented Mar 22, 2023

Summary

SUMMARY: Performance "Pass point by value"

Purpose of change

point only have two int member, x and y. that makes its size 8 bytes (64bit), the same size as pointer address in 64bit machine. passing value directly is faster for points because references needs to be dereferenced.

point tripoint
point tripoint
byValue is 1.2x faster byValue is 1.2x slower
  • passing point by value is 1.2x faster than by reference.
  • we don't do that for tripoints because it's 1.2x slower

Describe the solution

regex-replace const point & to point. couldn't change point_traits.h cause it uses references and cause weird ambiguities.

Describe alternatives you've considered

become average slow life enjoyer

Testing

image

before after
before after

had a break with debug monsters. it was on max ~13% faster. it could be due to other reasons, such as background processes, but gotta be optimistic here.

Additional context

@github-actions github-actions bot added the src changes related to source code. label Mar 22, 2023
@scarf005 scarf005 changed the title pass point as value pass point by value Mar 22, 2023
@scarf005 scarf005 changed the title pass point by value pass point by value (~13% performance improvement) Mar 22, 2023
@scarf005 scarf005 changed the title pass point by value (~13% performance improvement) pass point by value Mar 22, 2023
size of point of value and point pointer is same (8 bytes).
therefore passing point by value may improve performance.
Copy link
Collaborator

@joveeater joveeater left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@scarf005 scarf005 merged commit 097d420 into cataclysmbnteam:upload Mar 25, 2023
@scarf005 scarf005 deleted the point-as-value branch March 25, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants