public override bool Equals(RawText a, int ai, RawText b, int bi)
            {
                ai++;
                bi++;
                int @as = a.lines.Get(ai);
                int bs  = b.lines.Get(bi);
                int ae  = a.lines.Get(ai + 1);
                int be  = b.lines.Get(bi + 1);

                ae = RawCharUtil.TrimTrailingWhitespace(a.content, @as, ae);
                be = RawCharUtil.TrimTrailingWhitespace(b.content, bs, be);
                while (@as < ae && bs < be)
                {
                    byte ac = a.content[@as];
                    byte bc = b.content[bs];
                    while (@as < ae - 1 && RawCharUtil.IsWhitespace(ac))
                    {
                        @as++;
                        ac = a.content[@as];
                    }
                    while (bs < be - 1 && RawCharUtil.IsWhitespace(bc))
                    {
                        bs++;
                        bc = b.content[bs];
                    }
                    if (ac != bc)
                    {
                        return(false);
                    }
                    @as++;
                    bs++;
                }
                return(@as == ae && bs == be);
            }
            protected internal override int HashRegion(byte[] raw, int ptr, int end)
            {
                int hash = 5381;

                end = RawCharUtil.TrimTrailingWhitespace(raw, ptr, end);
                for (; ptr < end; ptr++)
                {
                    hash = ((hash << 5) + hash) + (raw[ptr] & unchecked ((int)(0xff)));
                }
                return(hash);
            }
            protected internal override int HashRegion(byte[] raw, int ptr, int end)
            {
                int hash = 5381;

                end = RawCharUtil.TrimTrailingWhitespace(raw, ptr, end);
                while (ptr < end)
                {
                    byte c = raw[ptr];
                    hash = ((hash << 5) + hash) + (c & unchecked ((int)(0xff)));
                    if (RawCharUtil.IsWhitespace(c))
                    {
                        ptr = RawCharUtil.TrimLeadingWhitespace(raw, ptr, end);
                    }
                    else
                    {
                        ptr++;
                    }
                }
                return(hash);
            }
Ejemplo n.º 4
0
                public override bool Equals(Text a, int ai, Text b, int bi)
                {
                    ai++;
                    bi++;
                    int @as = a._lines.Get(ai);
                    int bs  = b._lines.Get(bi);
                    int ae  = a._lines.Get(ai + 1);
                    int be  = b._lines.Get(bi + 1);

                    ae = RawCharUtil.TrimTrailingWhitespace(a.Content, @as, ae);
                    be = RawCharUtil.TrimTrailingWhitespace(b.Content, bs, be);
                    while (@as < ae && bs < be)
                    {
                        char ac = a.Content[@as];
                        char bc = b.Content[bs];
                        if (ac != bc)
                        {
                            return(false);
                        }
                        if (RawCharUtil.IsWhitespace(ac))
                        {
                            @as = RawCharUtil.TrimLeadingWhitespace(a.Content, @as, ae);
                        }
                        else
                        {
                            @as++;
                        }
                        if (RawCharUtil.IsWhitespace(bc))
                        {
                            bs = RawCharUtil.TrimLeadingWhitespace(b.Content, bs, be);
                        }
                        else
                        {
                            bs++;
                        }
                    }
                    return(@as == ae && bs == be);
                }
            public override bool Equals(RawText a, int ai, RawText b, int bi)
            {
                ai++;
                bi++;
                int @as = a.lines.Get(ai);
                int bs  = b.lines.Get(bi);
                int ae  = a.lines.Get(ai + 1);
                int be  = b.lines.Get(bi + 1);

                ae = RawCharUtil.TrimTrailingWhitespace(a.content, @as, ae);
                be = RawCharUtil.TrimTrailingWhitespace(b.content, bs, be);
                if (ae - @as != be - bs)
                {
                    return(false);
                }
                while (@as < ae)
                {
                    if (a.content[@as++] != b.content[bs++])
                    {
                        return(false);
                    }
                }
                return(true);
            }