Skip to content

Commit

Permalink
perf(gatsby-source-contentful): fix unguided search in loop over larg…
Browse files Browse the repository at this point in the history
…e lists (#28375)
  • Loading branch information
pvdz authored Nov 30, 2020
1 parent 5adfdcd commit d9904ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/gatsby-source-contentful/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,17 +499,17 @@ exports.sourceNodes = async (

reporter.verbose(`Resolving Contentful references`)

const newOrUpdatedEntries = []
const newOrUpdatedEntries = new Set()
entryList.forEach(entries => {
entries.forEach(entry => {
newOrUpdatedEntries.push(`${entry.sys.id}___${entry.sys.type}`)
newOrUpdatedEntries.add(`${entry.sys.id}___${entry.sys.type}`)
})
})

// Update existing entry nodes that weren't updated but that need reverse
// links added.
existingNodes
.filter(n => _.includes(newOrUpdatedEntries, `${n.id}___${n.sys.type}`))
.filter(n => newOrUpdatedEntries.has(`${n.id}___${n.sys.type}`))
.forEach(n => {
if (foreignReferenceMap[`${n.id}___${n.sys.type}`]) {
foreignReferenceMap[`${n.id}___${n.sys.type}`].forEach(
Expand Down

0 comments on commit d9904ac

Please sign in to comment.