diff options
| author | Elliott Hughes <enh@google.com> | 2017-11-30 23:18:19 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-11-30 23:18:19 +0000 |
| commit | aaa0bbce8eadf1a428493f3524066a74447eded4 (patch) | |
| tree | e406c455477d66f401cc8f0e6efafae0326a19a8 | |
| parent | f106bb6bb822740ea35b5974c2f137ef0a662648 (diff) | |
| parent | 1f93d71022cca7bb6bb9eec49693c511bf9f46a9 (diff) | |
| download | system_core-aaa0bbce8eadf1a428493f3524066a74447eded4.tar.gz system_core-aaa0bbce8eadf1a428493f3524066a74447eded4.tar.bz2 system_core-aaa0bbce8eadf1a428493f3524066a74447eded4.zip | |
Merge "use std::hash instead of hashing byte by byte"
| -rw-r--r-- | libziparchive/zip_archive.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc index 35d0f0b6a..6da5c99bd 100644 --- a/libziparchive/zip_archive.cc +++ b/libziparchive/zip_archive.cc @@ -100,6 +100,11 @@ static uint32_t RoundUpPower2(uint32_t val) { } static uint32_t ComputeHash(const ZipString& name) { +#if !defined(_WIN32) + return std::hash<std::string_view>{}( + std::string_view(reinterpret_cast<const char*>(name.name), name.name_length)); +#else + // Remove this code path once the windows compiler knows how to compile the above statement. uint32_t hash = 0; uint16_t len = name.name_length; const uint8_t* str = name.name; @@ -109,6 +114,7 @@ static uint32_t ComputeHash(const ZipString& name) { } return hash; +#endif } /* |
