tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit bad9fe1be695e458dd3d6dde2f4edc71b57b3602
parent 5f619a01632ea83cab635335cd530b2d33f0ba03
Author: Tooru Fujisawa <arai_a@mac.com>
Date:   Wed, 10 Dec 2025 10:27:00 +0000

Bug 2002960 - Part 2: Tweak the branches in ScriptLoader::OnStreamComplete to avoid unnecessary operations. r=nbp

Differential Revision: https://phabricator.services.mozilla.com/D274747

Diffstat:
Mdom/script/ScriptLoader.cpp | 33+++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp @@ -4109,28 +4109,25 @@ nsresult ScriptLoader::OnStreamComplete( aRequest->getLoadedScript()->SetCacheEntryId(id); } - } - // If we are loading from source, store the cache info channel and - // save the computed SRI hash or a dummy SRI hash in case we are going to - // save the this script in the disk cache. - if (aRequest->IsTextSource() && - StaticPrefs::dom_script_loader_bytecode_cache_enabled()) { - uint32_t fetchCount; - if (NS_SUCCEEDED(cacheInfo->GetCacheTokenFetchCount(&fetchCount))) { - if (fetchCount < UINT8_MAX) { - aRequest->getLoadedScript()->mFetchCount = fetchCount; - } else { - aRequest->getLoadedScript()->mFetchCount = UINT8_MAX; + // If we are loading from source, store the cache info channel and + // save the computed SRI hash or a dummy SRI hash in case we are going to + // save the this script in the disk cache. + if (aRequest->IsTextSource() && + StaticPrefs::dom_script_loader_bytecode_cache_enabled()) { + uint32_t fetchCount; + if (NS_SUCCEEDED(cacheInfo->GetCacheTokenFetchCount(&fetchCount))) { + if (fetchCount < UINT8_MAX) { + aRequest->getLoadedScript()->mFetchCount = fetchCount; + } else { + aRequest->getLoadedScript()->mFetchCount = UINT8_MAX; + } } - } - aRequest->getLoadedScript()->mCacheInfo = cacheInfo; - LOG(("ScriptLoadRequest (%p): nsICacheInfoChannel = %p", aRequest, - aRequest->getLoadedScript()->mCacheInfo.get())); + aRequest->getLoadedScript()->mCacheInfo = cacheInfo; + LOG(("ScriptLoadRequest (%p): nsICacheInfoChannel = %p", aRequest, + aRequest->getLoadedScript()->mCacheInfo.get())); - // We need the SRI hash only when the channel has cache info. - if (aRequest->getLoadedScript()->mCacheInfo) { rv = SaveSRIHash(aRequest, aSRIDataVerifier); } }