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

Removed all instances of gBitTable[x] #5123

Merged
merged 3 commits into from
Aug 17, 2024
Merged

Conversation

hedara90
Copy link
Collaborator

@hedara90 hedara90 commented Aug 8, 2024

Description

Removed all instances of gBitTable[x] and replaced them with (1u << (x)).
Added a migration script for replacing gBitTable[x] with (1u << (x)).

Issue(s) that this PR fixes

#5007

Discord contact info

hedara

@tertu-m
Copy link
Collaborator

tertu-m commented Aug 8, 2024

This is kind of pedantic, and other people could overrule me on this, but would it be possible to do at least some cleanup on the results? I'd like to get some more feedback from others as to whether that's necessary.
Another thought I had is maybe it would be better to have the template be something like (1u << (x))? This usually wouldn't matter but I worry about edge cases.

@hedara90
Copy link
Collaborator Author

hedara90 commented Aug 8, 2024

I'm unsure about what cleanup you're referring to.
I agree with the 1u thing, what's the best format for it? (u32)1 or 1u?

@tertu-m
Copy link
Collaborator

tertu-m commented Aug 9, 2024

I guess as far as cleanup I meant removing extra parens and stuff. At the very least there was a case where it was doing ((1<< (x)) << 16) and I think that should be rewritten into (1<< (x+16))

@hedara90
Copy link
Collaborator Author

hedara90 commented Aug 9, 2024

Oh, like that. I did not parse that in my head yesterday.
I kinda went with excessive parentheses, tests failed when I didn't.
20240809_18h18m33s_grim

I don't know if it's possible to make it output clean conversions, I can clean the usages in Expansion, but I kinda want to be on the safe side for the script.

@tertu-m
Copy link
Collaborator

tertu-m commented Aug 9, 2024

Oh, like that. I did not parse that in my head yesterday. I kinda went with excessive parentheses, tests failed when I didn't. 20240809_18h18m33s_grim

I don't know if it's possible to make it output clean conversions, I can clean the usages in Expansion, but I kinda want to be on the safe side for the script.

Oh yeah, in the general case, if you're trying to do a simple find and replace, the extra parentheses are necessary, and I don't see any issue with that. People can clean their code up later, and there won't be any performance penalty for it. I was just suggesting doing at least some cleanup for the expansion codebase.

@tertu-m
Copy link
Collaborator

tertu-m commented Aug 9, 2024

I'm unsure about what cleanup you're referring to. I agree with the 1u thing, what's the best format for it? (u32)1 or 1u?

I'd do 1u myself?

@hedara90
Copy link
Collaborator Author

hedara90 commented Aug 9, 2024

I was just suggesting doing at least some cleanup for the expansion codebase.

Yea, my brain was just locked in on somehow doing the cleanup in the script.

@hedara90
Copy link
Collaborator Author

Script output cleaned up

@Bassoonian Bassoonian changed the title Removed all instances of gBitTable[x] and made a migration script for it Removed all instances of gBitTable[x] Aug 10, 2024
@Bassoonian Bassoonian added type: refactor General Doesn't fit under other labels labels Aug 10, 2024
@tertu-m
Copy link
Collaborator

tertu-m commented Aug 11, 2024

So far this looks good. I'll fix up the conflict and then merge it.

@AlexOn1ine
Copy link
Collaborator

not a review but what does 1u mean?

@AsparagusEduardo
Copy link

not a review but what does 1u mean?

Pretty sure it's unsigned 1

@AsparagusEduardo
Copy link

Now the question is, is it needed?

@hedara90
Copy link
Collaborator Author

hedara90 commented Aug 14, 2024

20240814_09h07m44s_grim
It takes ~twice the time to make a gBitTable lookup compared to a bitshift.
And how did the table lookup work with the pre-fetch buffer?

@AlexOn1ine
Copy link
Collaborator

anything blocking this?

@AlexOn1ine
Copy link
Collaborator

@hedara90 can you update the description that a 1u is used instead 1?

@hedara90
Copy link
Collaborator Author

@hedara90 can you update the description that a 1u is used instead 1?

Done

@tertu-m tertu-m merged commit e4c81ba into rh-hideout:upcoming Aug 17, 2024
1 check passed
@tertu-m
Copy link
Collaborator

tertu-m commented Aug 17, 2024

Now the question is, is it needed?
I would say it’s not needed, but gBitTable’s existence in the first case is a bit of a misfeature.

Deokishisu added a commit to Deokishisu/FRLG-Plus that referenced this pull request Dec 13, 2024
`gBitTable[x]` takes nearly twice the time to complete as `(1u << x)` does, according to Hedara here: rh-hideout/pokeemerald-expansion#5123 , so it has been replaced.

Stolen from RHH, essentially. @luckytyphlosion seems to have been the first to mention it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Doesn't fit under other labels type: refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants