(long initial, @NotNull String name, int n)
| 167 | // 使用自己的hash算法,因为 TypeId 会持久化,不能因为算法改变导致值变化。 |
| 168 | // XXX: 这个算法定好之后,就不能变了。 |
| 169 | public static long hash64(long initial, @NotNull String name, int n) { |
| 170 | // This is a Knuth hash |
| 171 | long hashedValue = initial; |
| 172 | for (int i = 0; i < n; i++) |
| 173 | hashedValue = (hashedValue + name.charAt(i)) * 3074457345618258799L; |
| 174 | return hashedValue; |
| 175 | } |
| 176 | |
| 177 | public static long hash64(@NotNull String name, int n) { |
| 178 | return hash64(3074457345618258791L, name, n); |
no outgoing calls