mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 11:16:29 +03:00
ng_violet: make calcSplitRatio operation faster
Implements count_reachable in a less malloc-happy way, improving compile performance. Adds a count() function to small_color_map.
This commit is contained in:
committed by
Chang, Harry
parent
cadc7028b1
commit
08bf909e2b
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017-2018, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -114,6 +114,21 @@ public:
|
||||
std::memset(data->data(), val, data->size());
|
||||
}
|
||||
|
||||
size_t count(small_color color) const {
|
||||
assert(static_cast<u8>(color) < sizeof(fill_lut));
|
||||
size_t num = 0;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
size_t byte = i / entries_per_byte;
|
||||
assert(byte < data->size());
|
||||
size_t bit = (i % entries_per_byte) * bit_size;
|
||||
u8 val = ((*data)[byte] >> bit) & bit_mask;
|
||||
if (static_cast<small_color>(val) == color) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
small_color get_impl(key_type key) const {
|
||||
auto i = get(index_map, key);
|
||||
assert(i < n);
|
||||
|
Reference in New Issue
Block a user