php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
utils.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Alexander Borisov
3 *
4 * Author: Alexander Borisov <borisov@lexbor.com>
5 */
6
7#include "lexbor/core/utils.h"
8
9
10size_t
11lexbor_utils_power(size_t t, size_t k)
12{
13 size_t res = 1;
14
15 while (k) {
16 if (k & 1) {
17 res *= t;
18 }
19
20 t *= t;
21 k >>= 1;
22 }
23
24 return res;
25}
26
27size_t
28lexbor_utils_hash_hash(const lxb_char_t *key, size_t key_size)
29{
30 size_t hash, i;
31
32 for (hash = i = 0; i < key_size; i++) {
33 hash += key[i];
34 hash += (hash << 10);
35 hash ^= (hash >> 6);
36 }
37
38 hash += (hash << 3);
39 hash ^= (hash >> 11);
40 hash += (hash << 15);
41
42 return hash;
43}
zend_string * res
Definition ffi.c:4692
hash(string $algo, string $data, bool $binary=false, array $options=[])
Definition hash.stub.php:12
unsigned char key[REFLECTION_KEY_LEN]
unsigned char lxb_char_t
Definition types.h:27
size_t lexbor_utils_hash_hash(const lxb_char_t *key, size_t key_size)
Definition utils.c:28
size_t lexbor_utils_power(size_t t, size_t k)
Definition utils.c:11