Skip to content

Commit

Permalink
Attempt to silence warnings on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
finnschiermer committed May 27, 2024
1 parent 06b581f commit 7475efc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/realm/string_compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ void StringCompressor::add_expansion(SymbolDef def)
auto& chunk = m_expansion_storage.back();
auto start_index = (uint32_t)chunk.size();
if (def.expansion_a < 256)
chunk.push_back(def.expansion_a);
chunk.push_back((char)def.expansion_a);
else
chunk.append(m_symbols[def.expansion_a - 256].expansion);
if (def.expansion_b < 256)
chunk.push_back(def.expansion_b);
chunk.push_back((char)def.expansion_b);
else
chunk.append(m_symbols[def.expansion_b - 256].expansion);
std::string_view expansion(chunk.data() + start_index, exp_size);
Expand Down Expand Up @@ -115,7 +115,7 @@ void StringCompressor::rebuild_internal()
for (size_t i = m_symbols.size(); i < num_symbols; ++i) {
auto pair = m_data->get(i);
SymbolDef def;
def.id = i + 256;
def.id = (CompressionSymbol)(i + 256);
def.expansion_a = 0xFFFF & (pair >> 16);
def.expansion_b = 0xFFFF & pair;
auto hash = symbol_pair_hash(def.expansion_a, def.expansion_b);
Expand Down Expand Up @@ -167,7 +167,7 @@ CompressedString StringCompressor::compress(StringData sd, bool learn)
REALM_ASSERT_DEBUG(m_compression_map[hash].id == 0);
REALM_ASSERT_DEBUG(m_symbols.size() == m_data->size());
REALM_ASSERT_DEBUG(m_data->is_attached());
CompressionSymbol id = 256 + m_symbols.size();
CompressionSymbol id = (CompressionSymbol)(256 + m_symbols.size());
SymbolDef def{id, from[0], from[1]};
m_compression_map[hash] = def;
add_expansion(def);
Expand Down Expand Up @@ -215,7 +215,7 @@ std::string StringCompressor::decompress(CompressedStringView& c_str)
ptr = c_str.data;
while (ptr < limit) {
if (*ptr < 256)
result2.push_back(*ptr);
result2.push_back((char)*ptr);
else
result2.append(m_symbols[*ptr - 256].expansion);
ptr++;
Expand All @@ -225,7 +225,7 @@ std::string StringCompressor::decompress(CompressedStringView& c_str)
{
auto decompress = [&](CompressionSymbol symbol, auto& decompress) -> void {
if (symbol < 256) {
result.push_back(symbol);
result.push_back((char)symbol);
}
else {
auto& s = m_symbols[symbol - 256];
Expand Down
14 changes: 7 additions & 7 deletions src/realm/string_interner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ struct HashMapIter {
}
inline void set_index(size_t i, size_t search_limit = linear_search_limit)
{
index = i;
left_to_search = std::min(m_array.size(), (size_t)search_limit);
index = (uint16_t)i;
left_to_search = (uint16_t)std::min(m_array.size(), (size_t)search_limit);
}
void operator++()
{
Expand All @@ -103,10 +103,10 @@ static void rehash(Array& from, Array& to, uint8_t hash_size)
REALM_ASSERT_DEBUG(from.size() * 2 == to.size());

for (size_t i = 0; i < from.size(); ++i) {
auto entry = from.get(i);
auto entry = (size_t)from.get(i);
if ((entry >> hash_size) == 0)
continue;
auto starting_index = entry & (to.size() - 1);
size_t starting_index = entry & (to.size() - 1);
HashMapIter it(to, 0, hash_size);
it.set_index(starting_index);
while (it.is_valid() && !it.empty()) {
Expand Down Expand Up @@ -143,7 +143,7 @@ static void add_to_hash_map(Array& node, uint64_t hash, uint64_t id, uint8_t has
// it's a hash table. Grow if needed up till 'hash_node_max_size' entries
while (node.size() < hash_node_max_size) {
auto size = node.size();
auto start_index = hash & (size - 1);
size_t start_index = hash & (size - 1);
HashMapIter it(node, 0, hash_size);
it.set_index(start_index);
while (it.is_valid() && !it.empty()) {
Expand Down Expand Up @@ -338,7 +338,7 @@ void StringInterner::rebuild_internal()
if (e.m_weight == 0 && e.m_decompressed)
e.m_decompressed.reset();
}
size_t target_size = m_top->get_as_ref_or_tagged(Pos_Size).get_as_int();
size_t target_size = (size_t)m_top->get_as_ref_or_tagged(Pos_Size).get_as_int();
m_decompressed_strings.resize(target_size);
if (m_data->size() != m_compressed_leafs.size()) {
m_compressed_leafs.resize(m_data->size());
Expand Down Expand Up @@ -378,7 +378,7 @@ StringID StringInterner::intern(StringData sd)
m_decompressed_strings.push_back({64, std::make_unique<std::string>(sd)});
auto id = m_decompressed_strings.size();
add_to_hash_map(*m_hash_map.get(), h, id, 32);
size_t index = m_top->get_as_ref_or_tagged(Pos_Size).get_as_int();
size_t index = (size_t)m_top->get_as_ref_or_tagged(Pos_Size).get_as_int();
REALM_ASSERT_DEBUG(index == id - 1);
// Create a new leaf if needed (limit number of entries to 256 pr leaf)
if (!m_current_string_leaf->is_attached() || (index & 0xFF) == 0) {
Expand Down

0 comments on commit 7475efc

Please sign in to comment.