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

Optimize get_dangerous_tile, also is_ and prompt_ #76950

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

sparr
Copy link
Member

@sparr sparr commented Oct 10, 2024

Summary

Performance "Reduce unnecessary/duplicate checks for dangerous tiles"

Purpose of change

Dangerous tile checking currently runs the same checks multiple times, and enumerates more dangers than necessary in some cases.

Describe the solution

Add a parameter to get_dangerous_tile for the max number of dangers to return, and use that parameter in is_dangerous_tile which doesn't care if there's more than one.

Add a parameter to prompt_dangerous_tile to provide the list of dangers if it's already available.

Describe alternatives you've considered

I thought about trying to use an optional wrapped reference instead of a pointer for harmful_stuff but my efforts were significantly less readable.

Testing

I created some fields and traps and moved around them to produce various prompts.

Additional context

@sparr sparr force-pushed the optimize_get_dangerous_tile branch 2 times, most recently from 08c92d8 to 23e985b Compare October 10, 2024 19:04
src/game.cpp Show resolved Hide resolved
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) labels Oct 10, 2024
@sparr sparr force-pushed the optimize_get_dangerous_tile branch from 23e985b to 48d3b3b Compare October 10, 2024 19:59
@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Oct 10, 2024
@sparr sparr force-pushed the optimize_get_dangerous_tile branch from 48d3b3b to 7fa5c98 Compare October 12, 2024 12:40
@Maleclypse Maleclypse merged commit b7cfa5d into CleverRaven:master Oct 15, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants