diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-04-15 11:51:43 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-04-15 11:51:43 +0200 |
commit | bdd013826b8acbdef0ae43233d7a6a32e1161966 (patch) | |
tree | 83904a8337bfb28e1fa059afe5bc088a8b454688 /dom/fetch/InternalHeaders.h | |
parent | fca67bb95d4cda5046365e124e79ec583c336697 (diff) | |
parent | 8a95c03dcd2a7f2c6d64b6ee917f6cb363e9ca60 (diff) | |
download | UXP-bdd013826b8acbdef0ae43233d7a6a32e1161966.tar UXP-bdd013826b8acbdef0ae43233d7a6a32e1161966.tar.gz UXP-bdd013826b8acbdef0ae43233d7a6a32e1161966.tar.lz UXP-bdd013826b8acbdef0ae43233d7a6a32e1161966.tar.xz UXP-bdd013826b8acbdef0ae43233d7a6a32e1161966.zip |
Merge branch 'master' of https://github.com/MoonchildProductions/UXP
Diffstat (limited to 'dom/fetch/InternalHeaders.h')
-rw-r--r-- | dom/fetch/InternalHeaders.h | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/dom/fetch/InternalHeaders.h b/dom/fetch/InternalHeaders.h index e47066669..9a6d6dae7 100644 --- a/dom/fetch/InternalHeaders.h +++ b/dom/fetch/InternalHeaders.h @@ -45,14 +45,23 @@ private: HeadersGuardEnum mGuard; nsTArray<Entry> mList; + nsTArray<Entry> mSortedList; + + // This boolean is set to true at any writing operation to mList. It's set to + // false when mSortedList is regenerated. This happens when the header is + // iterated. + bool mListDirty; + public: explicit InternalHeaders(HeadersGuardEnum aGuard = HeadersGuardEnum::None) : mGuard(aGuard) + , mListDirty(false) { } explicit InternalHeaders(const InternalHeaders& aOther) : mGuard(HeadersGuardEnum::None) + , mListDirty(true) { ErrorResult result; Fill(aOther, result); @@ -79,19 +88,22 @@ public: bool Has(const nsACString& aName, ErrorResult& aRv) const; void Set(const nsACString& aName, const nsACString& aValue, ErrorResult& aRv); - uint32_t GetIterableLength() const + uint32_t GetIterableLength() { - return mList.Length(); + MaybeSortList(); + return mSortedList.Length(); } - const NS_ConvertASCIItoUTF16 GetKeyAtIndex(unsigned aIndex) const + const NS_ConvertASCIItoUTF16 GetKeyAtIndex(unsigned aIndex) { - MOZ_ASSERT(aIndex < mList.Length()); - return NS_ConvertASCIItoUTF16(mList[aIndex].mName); + MaybeSortList(); + MOZ_ASSERT(aIndex < mSortedList.Length()); + return NS_ConvertASCIItoUTF16(mSortedList[aIndex].mName); } - const NS_ConvertASCIItoUTF16 GetValueAtIndex(unsigned aIndex) const + const NS_ConvertASCIItoUTF16 GetValueAtIndex(unsigned aIndex) { - MOZ_ASSERT(aIndex < mList.Length()); - return NS_ConvertASCIItoUTF16(mList[aIndex].mValue); + MaybeSortList(); + MOZ_ASSERT(aIndex < mSortedList.Length()); + return NS_ConvertASCIItoUTF16(mSortedList[aIndex].mValue); } void Clear(); @@ -152,6 +164,9 @@ private: const nsACString& aValue); static bool IsRevalidationHeader(const nsACString& aName); + + void MaybeSortList(); + void SetListDirty(); }; } // namespace dom |