diff --git a/dom/indexedDB/Key.cpp b/dom/indexedDB/Key.cpp index cddd86c71a5e..8af963f2d5d8 100644 --- a/dom/indexedDB/Key.cpp +++ b/dom/indexedDB/Key.cpp @@ -123,16 +123,12 @@ IDBResult Key::SetFromString( // |aPos| should point to the type indicator. // The returned length doesn't include the type indicator // or the terminator. -static size_t LengthOfEncodedBinary(const unsigned char* aPos, - const unsigned char* aEnd) { +// static +uint32_t Key::LengthOfEncodedBinary(const EncodedDataType* aPos, + const EncodedDataType* aEnd) { MOZ_ASSERT(*aPos % Key::eMaxType == Key::eBinary, "Don't call me!"); - auto iter = ++aPos; - for (; iter < aEnd && *iter != Key::eTerminator; ++iter) { - if (*iter & 0x80) { - iter++; - } - } - return iter - aPos; + const EncodedDataType* encodedSectionEnd; + return CalcDecodedStringySize(aPos + 1, aEnd, &encodedSectionEnd); } IDBResult Key::ToLocaleBasedKey( diff --git a/dom/indexedDB/Key.h b/dom/indexedDB/Key.h index cdcea1ab93f9..17be6e6fb8d1 100644 --- a/dom/indexedDB/Key.h +++ b/dom/indexedDB/Key.h @@ -330,6 +330,9 @@ class Key { const EncodedDataType* aBegin, const EncodedDataType* aEnd, const EncodedDataType** aOutEncodedSectionEnd); + static uint32_t LengthOfEncodedBinary(const EncodedDataType* aPos, + const EncodedDataType* aEnd); + template static void DecodeAsStringy(const EncodedDataType* aEncodedSectionBegin, const EncodedDataType* aEncodedSectionEnd,