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

Memory and small runtime optimizations #1512

Merged
merged 1 commit into from
Nov 11, 2023

Conversation

Miepee
Copy link
Contributor

@Miepee Miepee commented Nov 5, 2023

Description

Does some small code and memory optimizations

Caveats

None that i'm aware of.

Notes

  • The custom "GetValueOrDefault" method was removed in favour of the same method in the standard library.
  • The assert has been giving a conditional, so that it does not even execute in release builds
  • The Block[] change has been done to remove memory overhead from enumerating over an IEnumerable
  • The foreach -> for change has been done, as the comment suggests, to reduce memory issues. I did a small benchmark, decompiling ~2000 code entries in AM2R, which saved almost a full gigabyte.
    Before this foreach change:
    grafik
    After the foreach change:
    grafik
    The mean time devation is ~1.1%, which could theoretically be margin of error.

Copy link

github-actions bot commented Nov 5, 2023

@colinator27
Copy link
Member

Generally looks good, although unsure about the conditional on Assert here. It's used to give errors in file parsing, and could lead to other problems, potentially... Maybe that just means we need another error function to handle those.

@Miepee
Copy link
Contributor Author

Miepee commented Nov 5, 2023

From what I can tell, it should be fine.
Whether you get an exception in release mode because the assert failed, or because something critical that depends on the assert right after failed, shouldnt make any difference.

@Miepee Miepee force-pushed the optimize-debug-out branch from e9a0605 to 42cdb90 Compare November 11, 2023 22:04
@colinator27 colinator27 merged commit 1beac06 into UnderminersTeam:master Nov 11, 2023
5 checks passed
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