← Back to Pull requests

[Perf] Assign standard properties in strict copies #167

Closed
unknown closed this pull request without merging on Nov 20, 2026 08:02 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 20:48 UTC
Author

Change

  • In copyStrict, the copier now assigns a standard property (configurable, enumerable and writable) to the clone, instead of a call to Object.defineProperty. It does this only when the prototype of the clone is Object.prototype, Array.prototype or null, and the property is not found on the clone. The result is the same own property.

  • The copier does not define a writable array length again when it is equal to the length of the clone.

  • Two new tests cover the guards: an own __proto__ property, and an array that ends with holes. Each test fails without its guard.
  • The output does not change.

    Performance

    node benchmark/index.js, ops/sec, median of 4 runs (Node 24, Apple M2 Max):

    | Object | main | This branch | Change |
    |---|---:|---:|---:|
    | simple (strict) | 1,699,047 | 3,730,200 | 2.20x |
    | complex (strict) | 79,041 | 109,378 | 1.38x |
    | big data (strict) | 206 | 442 | 2.15x |
    | circular (strict) | 1,521,251 | 2,505,992 | 1.65x |
    | special (strict) | 35,061 | 38,858 | 1.11x |

    In the same benchmark, loose copy of the complex object goes from 256,892 to 229,061 ops/sec. This branch does not change the loose code. When I run only the loose copy cases, main and this branch both give about 229,000 ops/sec. In main, the earlier strict cases make the later loose case faster.

    Checks:

  • npm run release:scripts passes.

  • Old and new outputs matched on 1M random values, with copy, copyStrict and custom copiers.

  • The built CJS output passes a smoke test on Node 10, 12 and 16.
  • Diff: 193 lines (+144 / -49) across 2 files Reviewer: g4lb Review duration: 673m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 193 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.315
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #167"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.0% (MEDIUM) · Higher = larger blast radius
    36.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.2% · Safe to merge
    14.2%