Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no longer attaching gpt slots to adUnits, which breaks utils.cloneJso… #1676

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions modules/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
utils.logWarn('no valid adUnits found, not loading ' + MODULE_NAME);
}

// store gpt slots in a more performant hash lookup by elementId (adUnit code)
var gptSlotCache = {};
// put adUnits in a more performant hash lookup by code.
var adUnitsCache = adUnits.reduce(function (cache, adUnit) {
if (adUnit.code && adUnit.bids) {
Expand Down Expand Up @@ -72,7 +74,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
const adUnit = adUnitsCache[elemId];

if (adUnit) {
adUnit._gptSlot = gptSlot;
gptSlotCache[elemId] = gptSlot; // store by elementId
adUnit.sizes = adUnit.sizes || mapGptSlotSizes(gptSlot.getSizes());
adUnits.push(adUnit);
gptSlots.splice(i, 1);
Expand Down Expand Up @@ -141,7 +143,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
$$PREBID_GLOBAL$$.setTargetingForGPTAsync();
fGptRefresh.apply(pads(), [
adUnits.map(function (adUnit) {
return adUnit._gptSlot;
return gptSlotCache[adUnit.code];
})
]);
}
Expand All @@ -157,7 +159,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
// get already displayed adUnits from aGptSlots if provided, else all defined gptSlots
aGptSlots = defaultSlots(aGptSlots);
var adUnits = pickAdUnits(/* mutated: */ aGptSlots).filter(function (adUnit) {
return adUnit._gptSlot._displayed;
return gptSlotCache[adUnit.code]._displayed;
});

if (aGptSlots.length) {
Expand All @@ -171,7 +173,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
$$PREBID_GLOBAL$$.setTargetingForGPTAsync();
fGptRefresh.apply(pads(), [
adUnits.map(function (adUnit) {
return adUnit._gptSlot
return gptSlotCache[adUnit.code];
}),
options
]);
Expand Down