Skip to content

Commit

Permalink
perf(gatsby): Use a Map instead of Object for job id lookups (#20605)
Browse files Browse the repository at this point in the history
A Map is designed for this work where an object will deoptimize after a handful of different keys.
  • Loading branch information
pvdz authored and GatsbyJS Bot committed Jan 15, 2020
1 parent b1e1d99 commit 54fb530
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/gatsby/src/query/query-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const pageDataUtil = require(`../utils/page-data`)
const { getCodeFrame } = require(`./graphql-errors`)
const { default: errorParser } = require(`./error-parser`)

const resultHashes = {}
const resultHashes = new Map()

type QueryJob = {
id: string,
Expand Down Expand Up @@ -99,8 +99,8 @@ module.exports = async (graphqlRunner, queryJob: QueryJob) => {
.update(resultJSON)
.digest(`base64`)

if (resultHashes[queryJob.id] !== resultHash) {
resultHashes[queryJob.id] = resultHash
if (resultHash !== resultHashes.get(queryJob.id)) {
resultHashes.set(queryJob.id, resultHash)

if (queryJob.isPage) {
const publicDir = path.join(program.directory, `public`)
Expand Down

0 comments on commit 54fb530

Please sign in to comment.