in reply to Re: Re: Re: Re: Matching First Character of Strings Efficiently
in thread Matching First Character of Strings Efficiently

kral,
I think you are misreading something. The first test by far surpassed the other two. In the first test you are using a long string, not a single character.

Additionally, it isn't that ord works better with only one character as an argument - it is that the other two are doing a lot more work. Using substr or split to get the first character is extra operations that are completely un-necessary. The ord function (perldoc -f ord) would work the same if it was a single character or a long string. It is for this reason that the second two tests take more time. They are doing un-necessary work.

I hope this clears things up - L~R
  • Comment on Re: Re: Re: Re: Re: Matching First Character of Strings Efficiently

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Matching First Character of Strings Efficiently
by kral (Monk) on Mar 16, 2004 at 20:13 UTC
    I think you are misreading something. The first test by far surpassed the other two. In the first test you are using a long string, not a single character.
    You're right! I have completely misunderstood the test's results. I'm so sorry!
    ----------
    kral
    (sorry for my english)