[caching] add grow method to the hint_array wrapper
This commit is contained in:
parent
17f7c982f2
commit
8408ab12f8
@ -106,6 +106,29 @@ namespace {
|
||||
switch (width) {
|
||||
#define xx(n) case n: return set_hint<n>(base, index, data)
|
||||
all_widths
|
||||
#undef xx
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------
|
||||
|
||||
template <uint32_t WIDTH>
|
||||
void grow(shared_ptr<array_base> base, unsigned new_nr_entries, vector<unsigned char> const &value) {
|
||||
typedef hint_traits<WIDTH> traits;
|
||||
typedef array<traits> ha;
|
||||
|
||||
shared_ptr<ha> a = dynamic_pointer_cast<ha>(base);
|
||||
if (!a)
|
||||
throw runtime_error("internal error: couldn't cast hint array");
|
||||
a->grow(new_nr_entries, value);
|
||||
}
|
||||
|
||||
void grow_(uint32_t width, shared_ptr<array_base> base,
|
||||
unsigned new_nr_entries, vector<unsigned char> const &value)
|
||||
{
|
||||
switch (width) {
|
||||
#define xx(n) case n: return grow<n>(base, new_nr_entries, value)
|
||||
all_widths
|
||||
#undef xx
|
||||
}
|
||||
}
|
||||
@ -144,4 +167,10 @@ hint_array::set_hint(unsigned index, vector<unsigned char> const &data)
|
||||
set_hint_(width_, impl_, index, data);
|
||||
}
|
||||
|
||||
void
|
||||
hint_array::grow(unsigned new_nr_entries, vector<unsigned char> const &value)
|
||||
{
|
||||
grow_(width_, impl_, new_nr_entries, value);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@ -47,6 +47,8 @@ namespace caching {
|
||||
void get_hint(unsigned index, vector<unsigned char> &data) const;
|
||||
void set_hint(unsigned index, vector<unsigned char> const &data);
|
||||
|
||||
void grow(unsigned new_nr_entries, vector<unsigned char> const &value);
|
||||
|
||||
private:
|
||||
unsigned width_;
|
||||
boost::shared_ptr<persistent_data::array_base> impl_;
|
||||
|
Loading…
Reference in New Issue
Block a user