tor-browser

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

commit e9679973391ec852d47ca2dcf72cd2f19e379827
parent b096c129a4a78302dbfb83d4a3a3f43c14deca2c
Author: Tooru Fujisawa <arai_a@mac.com>
Date:   Tue,  9 Dec 2025 05:11:36 +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); } }