[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Patch to pygame.sprite.AbstractGroup



Hello,

I've added the fix for using remove instead of add in AbstractGroup to cvs.

However the function refactorings are left out because of performance
concerns.  Despite your code looking oh so much nicer.


Cheers.


On 7/15/05, Ethan Glasser-Camp <glasse@xxxxxxx> wrote:
> If you look at pygame.sprite.AbstractGroup, you'll see that .add, .remove, and
> .has all share a great deal of duplicate code. Furthermore, .remove calls .add
> in one case, which is a bug that was probably introduced by copying the whole
> function and trying to tweak it accordingly. This patch removes these recursive
> cases from these functions and puts them in one function, ._slist, which turns
> the sprite argument into a simple flat list of sprites, regardless of whether
> it's a sprite, a list of sprites, a SpriteGroup, or any combination thereof.
> 
> This may cause a small efficiency hit on these functions, particularly .has,
> which ordinarily returns as soon as it finds a False response, but I believe it
> increases readability and maintainability by a comparable amount. Hope you apply.
> 
> Ethan
> 
> 
>