Which tag loop is faster?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/09/2006 at 01:23, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.102
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;---------
Which of these loops to get a particular type of tag on an object is faster (if there's any difference)?for (pt = obj->GetFirstTag(); pt; pt = pt->GetNext()) { if (!pt->IsInstanceOf(ID_IPPDIALTAG)) continue;
- OR -
for (LONG nr = 0; pt = obj->GetTag(ID_IPPDIALTAG, nr); nr++) {
Thanks,
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/09/2006 at 01:31, xxxxxxxx wrote:
The second one is kind of misused. The GetTag command will loop internally until it finds a tag of this type, so there´s no need for a loop.
It should therefore also be faster than the first one.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/09/2006 at 02:01, xxxxxxxx wrote:
Well, there is a need for a loop if you are getting 'all' of the similar tags on an object. That's why I ask since the most expedience in traversing a set of particular tags is required.
In this case, do you think that the first or second is more expedient?
Thanks,
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/09/2006 at 13:02, xxxxxxxx wrote:
I'd guess that the first is O(n) and the second O(n^2). So the first one should win.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/09/2006 at 14:03, xxxxxxxx wrote:
Is this because GetTag() initiates its own loop to traverse up to the next valid tag? If so, then time for some updating.
Thanks!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/09/2006 at 21:55, xxxxxxxx wrote:
That seems to settle it. There were something like 90+ of the GetTag() loops and all were replaced with the other type. The results definitely showed an improvement in speed.
Thank you very much - sometimes purile, but it is easier to ask and take advice than to change large areas of code blindly.
Robert
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/09/2006 at 07:02, xxxxxxxx wrote:
IT would be great if GetTag() would return the location of the found tag. That way one could go on from this position+1 to get the next tag in the row of the same type.
Take this as a suggestion Mikael