Skip to content

Commit c141f2b

Browse files
committed
Use SharedBuffer!=() in CachedResource::tryReplaceEncodedData()
https://bugs.webkit.org/show_bug.cgi?id=226943 Reviewed by Geoff Garen. Use SharedBuffer!=() in CachedResource::tryReplaceEncodedData() instead of duplicating its logic. SharedBuffer!=() is also potentially more efficient since it doesn't requires combining the SharedBuffers' data segments. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::tryReplaceEncodedData): Canonical link: https://commits.webkit.org/238750@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278793 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent a6efba9 commit c141f2b

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2021-06-11 Chris Dumez <cdumez@apple.com>
2+
3+
Use SharedBuffer!=() in CachedResource::tryReplaceEncodedData()
4+
https://bugs.webkit.org/show_bug.cgi?id=226943
5+
6+
Reviewed by Geoff Garen.
7+
8+
Use SharedBuffer!=() in CachedResource::tryReplaceEncodedData() instead of duplicating its logic.
9+
SharedBuffer!=() is also potentially more efficient since it doesn't requires combining the
10+
SharedBuffers' data segments.
11+
12+
* loader/cache/CachedResource.cpp:
13+
(WebCore::CachedResource::tryReplaceEncodedData):
14+
115
2021-06-11 Imanol Fernandez <ifernandez@igalia.com>
216

317
Implement Encode/Decode templates for WebXR InputSources

Source/WebCore/loader/cache/CachedResource.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -914,10 +914,10 @@ void CachedResource::tryReplaceEncodedData(SharedBuffer& newBuffer)
914914
if (!mayTryReplaceEncodedData())
915915
return;
916916

917-
// We have to do the memcmp because we can't tell if the replacement file backed data is for the
918-
// same resource or if we made a second request with the same URL which gave us a different
919-
// resource. We have seen this happen for cached POST resources.
920-
if (m_data->size() != newBuffer.size() || memcmp(m_data->data(), newBuffer.data(), m_data->size()))
917+
// We have to compare the buffers because we can't tell if the replacement file backed data is for the
918+
// same resource or if we made a second request with the same URL which gave us a different resource.
919+
// We have seen this happen for cached POST resources.
920+
if (*m_data != newBuffer)
921921
return;
922922

923923
m_data->clear();

0 commit comments

Comments
 (0)