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

Drop superfluous check for negative value of unsigned types #568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

janisozaur
Copy link
Contributor

No description provided.

@zeromus
Copy link
Contributor

zeromus commented Jul 21, 2022

I dont understand the significance of > sometimes and >= others.
This code is gross. Unsigned numbers are horrible. Can you please change the parameters to be ints instead?

@Aikku93
Copy link
Contributor

Aikku93 commented Jul 23, 2022

From what I can tell, srcPos >= list.size() makes sure that the source is somewhere /inside/ the list (as expected), while dstPos > list.size() uses > instead of >= because an item can be moved to the end of the list (ie. dstPos == list.size()).

As for signedness: While I'd argue that something's gone /seriously/ wrong if either of those values are out of bounds (or even negative) by the time move() is invoked, I think it really would be better to use int instead. At least on Windows (I can't seem to find references to move() on other platforms), s32 draggedItem and s32 highlightedItem are the values passed to the function, both of which are signed values that store -1 when in an 'invalid' state.

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.

None yet

3 participants