mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-14 05:55:13 +01:00
Address review
simplify code
This commit is contained in:
parent
2ec99b83aa
commit
db18f6c79a
@ -306,18 +306,10 @@ void LayeredFS::PrepareBuild(Directory& current) {
|
|||||||
// Implementation from 3dbrew
|
// Implementation from 3dbrew
|
||||||
u32 CalcHash(const std::string& name, u32 parent_offset) {
|
u32 CalcHash(const std::string& name, u32 parent_offset) {
|
||||||
u32 hash = parent_offset ^ 123456789;
|
u32 hash = parent_offset ^ 123456789;
|
||||||
|
|
||||||
std::u16string u16name = Common::UTF8ToUTF16(name);
|
std::u16string u16name = Common::UTF8ToUTF16(name);
|
||||||
std::vector<u16_le> tmp_buffer(u16name.size());
|
for (char16_t c : u16name) {
|
||||||
std::transform(u16name.begin(), u16name.end(), tmp_buffer.begin(), [](char16_t character) {
|
|
||||||
return static_cast<u16_le>(static_cast<u16>(character));
|
|
||||||
});
|
|
||||||
|
|
||||||
std::vector<u8> buffer(tmp_buffer.size() * 2);
|
|
||||||
std::memcpy(buffer.data(), tmp_buffer.data(), buffer.size());
|
|
||||||
for (std::size_t i = 0; i < buffer.size(); i += 2) {
|
|
||||||
hash = (hash >> 5) | (hash << 27);
|
hash = (hash >> 5) | (hash << 27);
|
||||||
hash ^= static_cast<u16>((buffer[i]) | (buffer[i + 1] << 8));
|
hash ^= static_cast<u16>(c);
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user