Skip to content

refactor: reduce array copies in OpenApiSchemaConverter#33

Merged
wadakatu merged 2 commits intomainfrom
refactor/schema-converter-in-place
Mar 17, 2026
Merged

refactor: reduce array copies in OpenApiSchemaConverter#33
wadakatu merged 2 commits intomainfrom
refactor/schema-converter-in-place

Conversation

@wadakatu
Copy link
Collaborator

Summary

  • convertRecursive, handleNullable, handlePrefixItems, removeKeys を参照渡しに変更し、中間配列コピーを削減
  • 再帰的なスキーマ変換時に各ステップで配列のコピーが生成されていたのを、in-place で変更するように修正
  • 深くネストされた OpenAPI スキーマでのメモリ割り当てを削減

Test plan

  • OpenApiSchemaConverterTest 全テスト通過
  • OpenApiResponseValidatorTest 全テスト通過
  • ResponseValidationTest (Integration) 全テスト通過
  • PHPStan エラーなし
  • PHP-CS-Fixer 違反なし

…maConverter

Change convertRecursive, handleNullable, handlePrefixItems, and removeKeys
to accept arrays by reference instead of by value. This eliminates
intermediate array copies created at each transformation step during
recursive schema conversion, reducing memory allocations for deeply
nested OpenAPI schemas.
Verify that convert() does not mutate the caller's input array, ensuring
the in-place optimization is safely encapsulated behind the value-passed
public API boundary.
@wadakatu wadakatu merged commit a836231 into main Mar 17, 2026
8 checks passed
@wadakatu wadakatu deleted the refactor/schema-converter-in-place branch March 17, 2026 09:13
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.

1 participant