Skip to content

Speed up URL/tag generation via Configuration clone fast-path#426

Merged
const-cloudinary merged 1 commit intomasterfrom
fix/configuration-clone-fast-path
Apr 26, 2026
Merged

Speed up URL/tag generation via Configuration clone fast-path#426
const-cloudinary merged 1 commit intomasterfrom
fix/configuration-clone-fast-path

Conversation

@const-cloudinary
Copy link
Copy Markdown
Member

Reduce per-asset/per-tag Configuration construction overhead and tighten a few hot paths exercised by URL building.

  • Add Configuration::__clone() that deep-clones every section so cloning the global singleton produces a fully independent working copy without the cost of a JSON import/export round-trip.
  • Use the clone fast-path in BaseAsset::fromParams, BaseTag::configuration (replaces a pre-existing TODO), and BaseTag::fromParamsDefaultConfig instead of new Configuration(...).
  • Memoize BaseConfigSection::exportableKeys() per (class, sensitivity) to eliminate repeated ReflectionClass::getConstants() calls on every config serialization.
  • Replace array_values(section)[0] with current(section) in the two jsonSerialize implementations.

Add tests/Unit/Configuration/ConfigurationCloneTest.php to lock in clone isolation across all configuration sections and across the asset/tag fast-paths, so a future regression to a shallow copy fails loudly.

Brief Summary of Changes

What does this PR address?

  • GitHub issue (Add reference - #XX)
  • Refactoring
  • New feature
  • Bug fix
  • Adds more tests

Are tests included?

  • Yes
  • No

Reviewer, please note:

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I ran the full test suite before pushing the changes and all of the tests pass.

Reduce per-asset/per-tag Configuration construction overhead and tighten
a few hot paths exercised by URL building.

- Add Configuration::__clone() that deep-clones every section so cloning the
  global singleton produces a fully independent working copy without the
  cost of a JSON import/export round-trip.
- Use the clone fast-path in BaseAsset::fromParams,
  BaseTag::configuration (replaces a pre-existing TODO), and
  BaseTag::fromParamsDefaultConfig instead of new Configuration(...).
- Memoize BaseConfigSection::exportableKeys() per (class, sensitivity) to
  eliminate repeated ReflectionClass::getConstants() calls on every config
  serialization.
- Replace array_values(section)[0] with current(section) in the two
  jsonSerialize implementations.

Add tests/Unit/Configuration/ConfigurationCloneTest.php to lock in clone
isolation across all configuration sections and across the asset/tag
fast-paths, so a future regression to a shallow copy fails loudly.
@const-cloudinary const-cloudinary merged commit a0a334b into master Apr 26, 2026
16 of 17 checks passed
@const-cloudinary const-cloudinary deleted the fix/configuration-clone-fast-path branch April 26, 2026 15:57
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