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) (#28404)

(cherry picked from commit d9904ac)

Co-authored-by: Peter van der Zee <209817+pvdz@users.noreply.github.com>
  • Loading branch information
GatsbyJS Bot and pvdz authored Dec 1, 2020
1 parent e444a55 commit 474dd36
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 474dd36

Please sign in to comment.