[Include] y_stringhash - Fast string comparisons.
#10

I think there is some confusion here - YHash and _H are not the same thing. _H is a compile-time macro that converts constant strings in to constant numbers. The results are not cached in an array as you suggested because there is no need, they are literally just numbers in the compiled code, no strings or hashings are present at run-time. YHash is the run-time equivalent, it takes unknown strings and hashes them while the server is running, for comparison with the pre-computed hashes of _H.

As for the length limits, I suspect you are not actually asking about YHash, which has no length limit for the reasons I just said, but _H, whose length limits are dictated by the compiler's line length limits. If you aren't already using Zeex's compiler, you should be, so try that on instead - it has a vastly increased line length limit. If you are, you could just be trying to has a very complex string, in which case I point you to this quote:

Quote:
Originally Posted by corne
Посмотреть сообщение
Important note: If your compiler hangs, consider using the old style on longer strings. This is not well suited to hashing long strings. For example:

Код:
case _I<color22>:
That will not compile because the generated line will be too long (but don't worry, the lines get optimised well, it's just a problem in the intermediate stages). On the other hand this will compile and will give the same answer:

Код:
case _I(c,o,l,o,r,2,2):
This way just doesn't look quite as nice.
The same applies to _H<> and _H(). The () syntax was the original version before I figured out how to parse arbitrary strings, but I kept it because the macros were MUCH simpler and can handle vastly longer strings. That second syntax is also the only one that supports spaces - you can't have them in the <> syntax.

Also, adding two hashes probably will not give the same result as hashing the concatenation of the two strings (in fact I know it won't - that would totally break the security of hashes, though these are not cryptographically secure ones, just basic comparison ones).
Reply


Messages In This Thread
y_stringhash - Fast string comparisons. - by corne - 17.04.2015, 19:17
Re: y_stringhash - Fast string comparisons. - by Kaperstone - 12.07.2017, 22:21
Re: y_stringhash - Fast string comparisons. - by Meller - 12.07.2017, 22:29
Re: y_stringhash - Fast string comparisons. - by xMoBi - 13.07.2017, 09:36
Re: y_stringhash - Fast string comparisons. - by Dayrion - 15.07.2017, 19:06
Re: y_stringhash - Fast string comparisons. - by PT - 15.07.2017, 22:54
Re: y_stringhash - Fast string comparisons. - by Astralis - 15.07.2017, 23:14
Re: y_stringhash - Fast string comparisons. - by Riddick94 - 16.07.2017, 15:43
Re: y_stringhash - Fast string comparisons. - by Kaperstone - 16.07.2017, 16:06
Re: y_stringhash - Fast string comparisons. - by Y_Less - 16.07.2017, 18:47
Re: y_stringhash - Fast string comparisons. - by Riddick94 - 18.07.2017, 18:06

Forum Jump:


Users browsing this thread: 1 Guest(s)