TVector empty isn't clear
by James Spellman · in Torque Game Engine · 08/26/2006 (5:42 pm) · 4 replies
This is a rant/bug report. Be prepared...
I was experiencing some strange crashes that turned out to be my fault because I misinterpreted the purpose of a the tVector method empty(). The bool empty() method checks to see if the element count is zero. It does not, as I would later come to understand, empty the vector like I assumed it would. I should have been using the clear() method all along. My bad.
I wish empty it was named a better. Would isEmpty have been so hard to think of? But it is the standard name, as far as I remember, so I guess we're stuck with it. Yup. Double-checked my STL Reference.
Anyway, so who else has fallen into this little trap? Well, fxShapeReplicator, around line 482 seems to be the only one I can find. It's that way in TSE too.
Edit: Go nuts with Markups and you're bound to make a mistake eventually.
I was experiencing some strange crashes that turned out to be my fault because I misinterpreted the purpose of a the tVector method empty(). The bool empty() method checks to see if the element count is zero. It does not, as I would later come to understand, empty the vector like I assumed it would. I should have been using the clear() method all along. My bad.
I wish empty it was named a better. Would isEmpty have been so hard to think of? But it is the standard name, as far as I remember, so I guess we're stuck with it. Yup. Double-checked my STL Reference.
Anyway, so who else has fallen into this little trap? Well, fxShapeReplicator, around line 482 seems to be the only one I can find. It's that way in TSE too.
Edit: Go nuts with Markups and you're bound to make a mistake eventually.
#2
should probably be:
08/28/2006 (11:40 am)
To highlight the problem, here's the code from fxShapeReplicator::DestroyShapes:// Empty the Replicated Shapes Vector.
mReplicatedShapes.empty();should probably be:
// Clear the Replicated Shapes Vector.
mReplicatedShapes.clear();
#3
This is still in 1.5. If it's not a bug, I'll shut up. If it is, I'll hold my breath until I die and/or someone takes note.
10/25/2006 (9:30 am)
BumpThis is still in 1.5. If it's not a bug, I'll shut up. If it is, I'll hold my breath until I die and/or someone takes note.
#4
empty is returning a value not performing any other real tasks.
so calling it and not using the return is useless.
so I am sure the intent would have been to "empty" the array :)
he should have been thinking "clear" not empty :)
stupid function anyhow that empty.. what a pos.
why not, isempty? or something? wtf..
10/25/2006 (9:48 am)
It is def a bug if that is the code.empty is returning a value not performing any other real tasks.
so calling it and not using the return is useless.
so I am sure the intent would have been to "empty" the array :)
he should have been thinking "clear" not empty :)
stupid function anyhow that empty.. what a pos.
why not, isempty? or something? wtf..
Associate Tom Spilman
Sickhead Games