- Joined
- Mar 2, 2012
- Messages
- 404
- Reaction score
- 217
- First Language
- English
- Primarily Uses
@Engr. Shana
You are running into a few bottlenecks with that approach due mainly to the system that you are building on:
1. You are doing a full refresh every time you need to draw the screen. You do not need to rebuild the data array just to scroll, you only need to draw the relevant items from the data array.
2. You are refreshing the screen more than needed (eg., every time the cursor moves, instead of when the page changes).
3. The way the Window determines which items are to be displayed is horribly inefficient for large lists. Every window will iterate over every single item the party has on every single refresh.
4. The same with the way the item data is stored and retrieved. For example, armors iterates over an array of ids and gets the actual object and puts it in another array which is done every time it is accessed. It then sorts that array, iterating it again. This compounds with the above for some very long lookup times when dealing with large lists.
5. Window_BattleItem further iterates through every single item in the window to find one that matches the last selection, which is why it is even more pronounced in this.
Basically, we can't just consider how the window handles and draws data, we have to consider how it is handled by the system as a whole. A simple way to minimize bottlenecks due to a given costly algorithm would be to overlay a temporary cache on the accessor so the algorithm does not get run more than necessary, clearing the cache only if the underlying data is changed so it is rebuilt on next lookup. That may or may not be sufficient, since a single lookup on a single method is still as many iterations as you have items, and many of these methods iterate. A real fix would require changing how the data is managed as a whole.
On the plus side, when tested done with reasonable numbers of items, I have no notable slowdown from drawing a full page of items at a time, even without using my Text Cache script, so it is a solid proof of concept for by-page drawing.
You are running into a few bottlenecks with that approach due mainly to the system that you are building on:
1. You are doing a full refresh every time you need to draw the screen. You do not need to rebuild the data array just to scroll, you only need to draw the relevant items from the data array.
2. You are refreshing the screen more than needed (eg., every time the cursor moves, instead of when the page changes).
3. The way the Window determines which items are to be displayed is horribly inefficient for large lists. Every window will iterate over every single item the party has on every single refresh.
4. The same with the way the item data is stored and retrieved. For example, armors iterates over an array of ids and gets the actual object and puts it in another array which is done every time it is accessed. It then sorts that array, iterating it again. This compounds with the above for some very long lookup times when dealing with large lists.
5. Window_BattleItem further iterates through every single item in the window to find one that matches the last selection, which is why it is even more pronounced in this.
Basically, we can't just consider how the window handles and draws data, we have to consider how it is handled by the system as a whole. A simple way to minimize bottlenecks due to a given costly algorithm would be to overlay a temporary cache on the accessor so the algorithm does not get run more than necessary, clearing the cache only if the underlying data is changed so it is rebuilt on next lookup. That may or may not be sufficient, since a single lookup on a single method is still as many iterations as you have items, and many of these methods iterate. A real fix would require changing how the data is managed as a whole.
On the plus side, when tested done with reasonable numbers of items, I have no notable slowdown from drawing a full page of items at a time, even without using my Text Cache script, so it is a solid proof of concept for by-page drawing.


