Пример #1
0
        int GetHashCodeInternal(bool ignoreMessageTime)
        {
            // The primary source of the hash is message's position. But it is not the only source,
            // we have to use the other fields because messages might be at the same position
            // but be different. That might happen, for example, when a message was at the end
            // of the live stream and wasn't read completely. As the stream grows the same message
            // will be fully written and might be eventually read again.
            // Those two message might be different, thought they are at the same position.

            int ret = Hashing.GetStableHashCode(position);

            ret ^= text.GetStableHashCode();

            if (!ignoreMessageTime)
            {
                ret = MessagesUtils.XORTimestampHash(ret, time);
            }
            if (thread != null)
            {
                ret ^= Hashing.GetStableHashCode(thread.ID);
            }
            ret ^= (int)(flags & MessageFlag.ContentTypeMask);

            return(ret);
        }
Пример #2
0
        int GetHashCodeInternal(bool ignoreMessageTime)
        {
            // The primary source of the hash is message's position. But it is not the only source,
            // we have to use the other fields because messages might be at the same position
            // but be different. That might happen, for example, when a message was at the end
            // of the live stream and wasn't read completely. As the stream grows the same message
            // will be fully written and might be eventually read again.
            // Those two message might be different, thought they are at the same position.

            int ret = Hashing.GetStableHashCode(position);

            // Don't hash Text for frame-end beacause it doesn't have its own permanent text.
            // It takes the text from brame begin instead. The link to frame begin may change
            // during the time (it may get null or not null).
            if ((flags & MessageFlag.TypeMask) != MessageFlag.EndFrame)
            {
                ret ^= DoGetText().GetStableHashCode();
            }

            if (!ignoreMessageTime)
            {
                ret = MessagesUtils.XORTimestampHash(ret, time);
            }
            if (thread != null)
            {
                ret ^= Hashing.GetStableHashCode(thread.ID);
            }
            ret ^= (int)(flags & (MessageFlag.TypeMask | MessageFlag.ContentTypeMask));

            return(ret);
        }