diff options
author | dan <dan.abramov@gmail.com> | 2024-04-27 07:54:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-27 07:54:47 +0100 |
commit | 21e5a87fabf277ebf637a7bd13d7bebd31494c9a (patch) | |
tree | b89ccdec2caa148bb39d55dd525aa51e5e726aac /patches | |
parent | 61d7e6014b13bbb53046d84867cc37daf944198f (diff) | |
download | voidsky-21e5a87fabf277ebf637a7bd13d7bebd31494c9a.tar.zst |
Patch lexicon for perf (#3733)
Diffstat (limited to 'patches')
-rw-r--r-- | patches/@atproto+lexicon+0.4.0.patch | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/patches/@atproto+lexicon+0.4.0.patch b/patches/@atproto+lexicon+0.4.0.patch new file mode 100644 index 000000000..4643db32a --- /dev/null +++ b/patches/@atproto+lexicon+0.4.0.patch @@ -0,0 +1,28 @@ +diff --git a/node_modules/@atproto/lexicon/dist/validators/complex.js b/node_modules/@atproto/lexicon/dist/validators/complex.js +index 32d7798..9d688b7 100644 +--- a/node_modules/@atproto/lexicon/dist/validators/complex.js ++++ b/node_modules/@atproto/lexicon/dist/validators/complex.js +@@ -113,7 +113,22 @@ function object(lexicons, path, def, value) { + if (value[key] === null && nullableProps.has(key)) { + continue; + } +- const propDef = def.properties[key]; ++ const propDef = def.properties[key] ++ if (typeof value[key] === 'undefined' && !requiredProps.has(key)) { ++ // Fast path for non-required undefined props. ++ if ( ++ propDef.type === 'integer' || ++ propDef.type === 'boolean' || ++ propDef.type === 'string' ++ ) { ++ if (typeof propDef.default === 'undefined') { ++ continue ++ } ++ } else { ++ // Other types have no defaults. ++ continue ++ } ++ } + const propPath = `${path}/${key}`; + const validated = (0, util_1.validateOneOf)(lexicons, propPath, propDef, value[key]); + const propValue = validated.success ? validated.value : value[key]; |