[Ohrrpgce] FirstChild vs GetChildByName

Ralph Versteegen teeemcee at gmail.com
Fri May 6 03:49:24 PDT 2016


On 6 May 2016 at 22:40, Ralph Versteegen <teeemcee at gmail.com> wrote:
> On 6 May 2016 at 10:01, James Paige <Bob at hamsterrepublic.com> wrote:
>> I just noticed that the reload functions FirstChild and GetChildByName seem
>> to be almost exactly the same.
>>
>> GetChildByName's name argument is not optional, and it has something that
>> appears to be a speed optimization
>>
>> Is there any reason not to combine them? (probably by removing
>> GetChildByName, and maybe adding its optimization to FirstChild?)
>>
>> ---
>> James
>
> Yes, they could be combined, if "GetChildByName" in reloadbasic.py is
> also replaced. The only possible reason not to is that it's not
> obvious that the two functions are equivalent, so you won't know to
> look for one when you want the other. I guess FirstChild may be the
> better name because it's short :) and because it draws attention to
> the fact that you get the other children with that name with
> NextSibling. Alternatively we could removing the name argument to
> FirstChild so there's no overlap.
Hmm, but that wouldn't make much sense unless we also split
Next/PreviousSibling into two functions each.
We've also got a lot of functions related to GetChildByName, like
GetChildNodeInt, etc, FindChildByName, GetOrCreateChild. I wish I knew
how to make it more intuitive.

> I hardly remember adding that optimisation to GetChildByName, but
> would like to keep it.


More information about the Ohrrpgce mailing list