GitSharp.Core.Util.RawSubStringPattern.match C# (CSharp) Method

match() public method

public match ( GitSharp.Core.Util.RawCharSequence rcs ) : int
rcs GitSharp.Core.Util.RawCharSequence
return int
        public int match(RawCharSequence rcs)
        {
            int needleLen = needle.Length;
            byte first = needle[0];

            byte[] text = rcs.buffer;
            int matchPos = rcs.startPtr;
            int maxPos = rcs.endPtr - needleLen;

            for (; matchPos < maxPos; matchPos++)
            {
                if (neq(first, text[matchPos]))
                {
                    while (++matchPos < maxPos && neq(first, text[matchPos]))
                    {
                        /* skip */
                    }
                    if (matchPos == maxPos)
                        return -1;
                }

                int si = ++matchPos;

                bool outer_continue = false;
                for (int j = 1; j < needleLen; j++, si++)
                {
                    if (neq(needle[j], text[si]))
                        outer_continue = true;
                }

                if (outer_continue)
                    continue;

                return matchPos - 1;
            }
            return -1;
        }