-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Dont recreate stackables every move #4761
base: master
Are you sure you want to change the base?
Conversation
if (newCount == item->getItemCount()) { | ||
// full item is moved (move count is the same as item count) | ||
} else if (newCount > 0) { | ||
moveItem = item->clone(); | ||
moveItem->setItemCount(newCount); | ||
} else { | ||
if (item->isRemoved()) { | ||
ReleaseItem(item); | ||
} | ||
|
||
moveItem = nullptr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming the new count can never be negative, how about this?
if (newCount == item->getItemCount()) { | |
// full item is moved (move count is the same as item count) | |
} else if (newCount > 0) { | |
moveItem = item->clone(); | |
moveItem->setItemCount(newCount); | |
} else { | |
if (item->isRemoved()) { | |
ReleaseItem(item); | |
} | |
moveItem = nullptr; | |
} | |
assert(newCount >= 0); | |
if (newCount != item->getItemCount()) { | |
moveItem = item->clone(); | |
moveItem->setItemCount(newCount); | |
} else if (newCount == 0) { | |
if (item->isRemoved()) { | |
ReleaseItem(item); | |
} | |
moveItem = nullptr; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attention: the code above may cause duplication bugs that I couldn't trace. Please don't apply it without testing beforehand.
Pull Request Prelude
Changes Proposed
Don't recreate stackables on every move, create new stackables only when splitting the stack.
Issues addressed:
Stackable items are recreated even when they shouldn't, if you move a full stack of stackable item, why would you create a new item and delete the old one?
This seems pretty wasteful and unnecessary.