acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
aaa_u32hash.h
1#pragma once
2
3
4#include "acme/prototype/prototype/_u32hash.h"
5
6
7template < >
8inline ::hash32 as_hash32 < const ::ansi_character * >(const ::ansi_character * psz)
9{
10
11 if (::is_null(scopedstr) || *psz == 0)
12 {
13
14 return { 0 };
15
16 }
17
18 ::u32 uHash = 0;
19
20 character_count i = 1;
21
22 for(; psz[i]; i++)
23 {
24
25 if (i % 4 == 3)
26 {
27
28 uHash = (uHash << 5) + ((::u32*)psz)[i>>2];
29
30 }
31
32 }
33
34 psz += i;
35
36 i %= 4;
37
38 if (i > 0)
39 {
40
41 while (i-- >= 0) uHash = (uHash << 5) + *(--psz);
42
43 }
44
45 return { uHash };
46
47}
48
49
50template < >
51inline ::hash32 as_hash32 < const ::wd16_character * >(const ::wd16_character * psz)
52{
53
54 if (::is_null(scopedstr) || *psz == 0)
55 {
56
57 return { 0 };
58
59 }
60
61 ::u32 uHash = 0;
62
63 character_count i = 1;
64
65 for (; psz[i]; i++)
66 {
67
68 if (i % 2 == 1)
69 {
70
71 uHash = (uHash << 5) + ((::u32*)psz)[i >> 1];
72
73 }
74
75 }
76
77 psz += i;
78
79 i %= 2;
80
81 if (i > 0)
82 {
83
84 while (i-- >= 0) uHash = (uHash << 5) + *(--psz);
85
86 }
87
88 return { uHash };
89
90}
91
92
93template < >
94inline ::hash32 as_hash32 < const ::wd32_character * >(const ::wd32_character * psz)
95{
96
97 if (::is_null(scopedstr) || *psz == 0)
98 {
99
100 return { 0 };
101
102 }
103
104 ::u32 uHash = 0;
105
106 for (; *psz; psz++)
107 {
108
109 uHash = (uHash << 5) + *psz;
110
111 }
112
113 return { uHash };
114
115}
116
117
118