Skip to content

Commit

Permalink
Fix warnings about signed and unsigned comparisons.
Browse files Browse the repository at this point in the history
  • Loading branch information
BYVoid committed Jul 27, 2024
1 parent d1ca946 commit f34b3bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/BinaryDict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ BinaryDictPtr BinaryDict::NewFromFile(FILE* fp) {
throw InvalidFormat("Invalid OpenCC binary dictionary (numValues)");
}
// Key offset
size_t keyOffset;
unitsRead = fread(&keyOffset, sizeof(size_t), 1, fp);
long keyOffset;
unitsRead = fread(&keyOffset, sizeof(long), 1, fp);
if (unitsRead != 1 || keyOffset >= offsetBound) {
throw InvalidFormat("Invalid OpenCC binary dictionary (keyOffset)");
}
std::string key = dict->keyBuffer.c_str() + keyOffset;
// Value offset
std::vector<std::string> values;
for (size_t j = 0; j < numValues; j++) {
size_t valueOffset;
unitsRead = fread(&valueOffset, sizeof(size_t), 1, fp);
long valueOffset;
unitsRead = fread(&valueOffset, sizeof(long), 1, fp);
if (unitsRead != 1 || valueOffset >= offsetBound) {
throw InvalidFormat("Invalid OpenCC binary dictionary (valueOffset)");
}
Expand Down
8 changes: 4 additions & 4 deletions src/PhraseExtract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ class PhraseExtract::DictType {
}

void BuildTrie() {
std::unordered_map<std::string, int> key_item_id_map;
std::unordered_map<std::string, size_t> key_item_id_map;
marisa::Keyset keyset;
for (int i = 0; i < items.size(); i++) {
for (size_t i = 0; i < items.size(); i++) {
const auto& key = items[i].first;
key_item_id_map[key.ToString()] = i;
keyset.push_back(key.CString(), key.ByteLength());
Expand All @@ -117,7 +117,7 @@ class PhraseExtract::DictType {
if (it == key_item_id_map.end()) {
throw ShouldNotBeHere();
}
int item_id = it->second;
size_t item_id = it->second;
marisa_id_item_map[marisa_id] = item_id;
}
}
Expand All @@ -127,7 +127,7 @@ class PhraseExtract::DictType {
dict;
std::vector<ItemType> items;
marisa::Trie marisa_trie;
std::vector<int> marisa_id_item_map;
std::vector<size_t> marisa_id_item_map;
};

using namespace internal;
Expand Down

0 comments on commit f34b3bd

Please sign in to comment.