Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › hash › cityhash › CityHash64 › hashLen0To16 Private Function hashLen0To16 Doc Source Private Function std.hash.cityhash.CityHash64.hashLen0To16
fn hashLen0To16 (str : []const u8 ) u64 Params File hash/cityhash.zig: 204
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228 fn hashLen0To16 (str : []const u8 ) u64 {
const len : u64 = @as (u64 , str .len );
if (len >= 8 ) {
const mul : u64 = k2 +% len *% 2 ;
const a : u64 = fetch64 (str .ptr , 0 ) +% k2 ;
const b : u64 = fetch64 (str .ptr , str .len - 8 );
const c : u64 = rotr64 (b , 37 ) *% mul +% a ;
const d : u64 = (rotr64 (a , 25 ) +% b ) *% mul ;
return hashLen16Mul (c , d , mul );
}
if (len >= 4 ) {
const mul : u64 = k2 +% len *% 2 ;
const a : u64 = fetch32 (str .ptr , 0 );
return hashLen16Mul (len +% (a << 3 ), fetch32 (str .ptr , str .len - 4 ), mul );
}
if (len > 0 ) {
const a : u8 = str [0 ];
const b : u8 = str [str .len >> 1 ];
const c : u8 = str [str .len - 1 ];
const y : u32 = @as (u32 , @intCast (a )) +% (@as (u32 , @intCast (b )) << 8 );
const z : u32 = @as (u32 , @truncate (str .len )) +% (@as (u32 , @intCast (c )) << 2 );
return shiftmix (@as (u64 , @intCast (y )) *% k2 ^ @as (u64 , @intCast (z )) *% k0 ) *% k2 ;
}
return k2 ;
}