ldb::Slice dev::eth::toSlice(h256 const& _h, unsigned _sub) { #if ALL_COMPILERS_ARE_CPP11_COMPLIANT static thread_local FixedHash<33> h = _h; h[32] = (uint8_t)_sub; return (ldb::Slice)h.ref(); #else static boost::thread_specific_ptr<FixedHash<33>> t_h; if (!t_h.get()) t_h.reset(new FixedHash<33>); *t_h = FixedHash<33>(_h); (*t_h)[32] = (uint8_t)_sub; return (ldb::Slice)t_h->ref(); #endif //ALL_COMPILERS_ARE_CPP11_COMPLIANT }
ldb::Slice dev::eth::toSlice(uint64_t _n, unsigned _sub) { #if ALL_COMPILERS_ARE_CPP11_COMPLIANT static thread_local FixedHash<33> h; toBigEndian(_n, bytesRef(h.data() + 24, 8)); h[32] = (uint8_t)_sub; return (ldb::Slice)h.ref(); #else static boost::thread_specific_ptr<FixedHash<33>> t_h; if (!t_h.get()) t_h.reset(new FixedHash<33>); bytesRef ref(t_h->data() + 24, 8); toBigEndian(_n, ref); (*t_h)[32] = (uint8_t)_sub; return (ldb::Slice)t_h->ref(); #endif }