2008-07-06, 16:06
Jmarshall,
I just synced up and took a look at your changes. I actually thought about this exact scenario. Whether or not this is more efficient depends on the percentage of items that get stacked. If there are very few stackable items, the code is now less efficient as its unnecesarily resetting the show watched overlay and the fanart property.
The compromise would be to decleare a bool outside the inner loop and set it to true if the inner loop finds a match, and use that after the inner loop exits to change those properties if required. Something like this (pseudo-code):
I just synced up and took a look at your changes. I actually thought about this exact scenario. Whether or not this is more efficient depends on the percentage of items that get stacked. If there are very few stackable items, the code is now less efficient as its unnecesarily resetting the show watched overlay and the fanart property.
The compromise would be to decleare a bool outside the inner loop and set it to true if the inner loop finds a match, and use that after the inner loop exits to change those properties if required. Something like this (pseudo-code):
Code:
while (i < size)
get(i)
j = i + 1
bool bMatched = false
while (j < size)
get(j)
if (i.title == j.title)
bMatched = true
update(i)
remove(j)
else break
if (bMatched)
update_more(i)
i = j