MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / normalize_index

Function normalize_index

deps/hdr_histogram/hdr_histogram.c:27–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25/* ###### ####### ####### ## ## ## ###### */
26
27static int32_t normalize_index(const struct hdr_histogram* h, int32_t index)
28{
29 int32_t normalized_index;
30 int32_t adjustment = 0;
31 if (h->normalizing_index_offset == 0)
32 {
33 return index;
34 }
35
36 normalized_index = index - h->normalizing_index_offset;
37
38 if (normalized_index < 0)
39 {
40 adjustment = h->counts_len;
41 }
42 else if (normalized_index >= h->counts_len)
43 {
44 adjustment = -h->counts_len;
45 }
46
47 return normalized_index + adjustment;
48}
49
50static int64_t counts_get_direct(const struct hdr_histogram* h, int32_t index)
51{

Callers 3

counts_get_normalisedFunction · 0.85
counts_inc_normalisedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected