Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

Summary

Got another 50% speedup on #15672 by removing modifiedPaths() from setDefaultsOnInsert, and then similar results if runValidators is set by removing modifiedPaths() from update validators (which was very easy since it turns out runValidators doesn't even use modifiedPaths)

Examples

@vkarpov15 vkarpov15 added this to the 8.19.2 milestone Oct 18, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes performance for setDefaultsOnInsert and update validators by eliminating unnecessary modifiedPaths() computations. The change achieves a 50% speedup by only calculating modified paths when there are actual defaults to set.

Key changes:

  • Added early return in getDefault() when defaultValue is null
  • Removed modifiedPaths() calls from update validators since they weren't being used
  • Refactored setDefaultsOnInsert to check path modifications inline instead of pre-computing all modified paths

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/schemaType.js Added null check for early return in getDefault() to avoid unnecessary computation
lib/helpers/updateValidators.js Removed unused modifiedPaths import and all related computation
lib/helpers/setDefaultsOnInsert.js Replaced pre-computed modified paths with inline path checking, optimized operator detection using charAt(0)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@vkarpov15 vkarpov15 merged commit dd39133 into master Oct 19, 2025
74 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-15672-3 branch October 20, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants