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

Re-implement lookaside for DFS during resolution #1209

Merged
merged 1 commit into from
Dec 20, 2017
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
17 changes: 14 additions & 3 deletions src/specmap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class SpecMap {
// We might consider making this (traversing & application) configurable later.
function createKeyBasedPlugin(pluginObj) {
return function* (patches, specmap) {
const refCache = {}

for (const patch of patches.filter(lib.isAdditiveMutation)) {
yield* traverse(patch.value, patch.path, patch)
}
Expand All @@ -98,13 +100,22 @@ class SpecMap {
const parent = path[parentIndex]
const indexOfFirstProperties = path.indexOf('properties')
const isRootProperties = parent === 'properties' && parentIndex === indexOfFirstProperties
const traversed = specmap.allowMetaPatches && refCache[obj.$$ref]

for (const key of Object.keys(obj)) {
const val = obj[key]
const updatedPath = path.concat(key)

if (lib.isObject(val)) {
yield* traverse(val, updatedPath, patch)
const isObj = lib.isObject(val)
const objRef = obj.$$ref

if (!traversed) {
if (isObj) {
// Only store the ref if it exists
if (specmap.allowMetaPatches && objRef) {
refCache[objRef] = true
}
yield* traverse(val, updatedPath, patch)
}
}

if (!isRootProperties && key === pluginObj.key) {
Expand Down