Speed-up path element operations & comparisons

Avoid repeated expensive operations in `STPathElement` (e.g. calls to `base_uint::isZero`) and attempt to make comparisons of path elements faster by calculating a path id and using it to avoid expensive comparisons between `base_uint` objects.

This is pending a performance review.
(pedantic) Actually, the fact that 65537 is a prime isn't the key thing -
but that 65537 is relatively prime to the modulus of our number system.
 Which is any odd number. We get better performance out of this choice
because we're very close to the square root of the modulus.  But that'd
work fine even if 2^bits + 1 weren't an actual prime...


On Fri, Aug 22, 2014 at 4:26 PM, Nik Bougalis <notifications@github.com>
wrote:

> In src/ripple/module/data/protocol/SerializedTypes.h:
>
> > @@ -192,29 +192,62 @@ class STPathElement
> >                                  // Combination of all types.
> >      };
> >
> > +private:
> > +    static
> > +    std::size_t
> > +    get_hash (STPathElement const& element)
> > +    {
> > +        std::size_t hash = 2654435761;
> > +
> > +        // NIKB NOTE: This doesn't have to be a secure hash as speed is more
> > +        //            important. We don't even need to fully hash the whole
> > +        //            base_uint here, as a few bytes would do for our use.
> > +
> > +        for (auto const x : element.getAccountID ())
>
> How about static uint32_t const prime_65537 = 65537? [image: :tada:]
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/ripple/rippled/pull/525/files#r16619492>.
>