[Ohrrpgce] FirstChild vs GetChildByName

James Paige Bob at HamsterRepublic.com
Fri May 6 05:05:56 PDT 2016


Now that I think about it some more, I am inclined to leave both functions
alone, and just add some comments to the source about their equivalency

On Friday, May 6, 2016, Ralph Versteegen <teeemcee at gmail.com> wrote:

> On 6 May 2016 at 22:40, Ralph Versteegen <teeemcee at gmail.com
> <javascript:;>> wrote:
> > On 6 May 2016 at 10:01, James Paige <Bob at hamsterrepublic.com
> <javascript:;>> 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.
> _______________________________________________
> Ohrrpgce mailing list
> ohrrpgce at lists.motherhamster.org <javascript:;>
> http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20160506/876564c3/attachment.htm>


More information about the Ohrrpgce mailing list