Skip to content

core: improve id generation#2584

Merged
lucas-koehler merged 2 commits into
masterfrom
id-generation
Jun 2, 2026
Merged

core: improve id generation#2584
lucas-koehler merged 2 commits into
masterfrom
id-generation

Conversation

@sdirix
Copy link
Copy Markdown
Member

@sdirix sdirix commented May 28, 2026

  • Makes id generation overridable
  • Improves the worst case in current id generation by keeping tab on the next open count
  • Keeps current visible behavior the same as before

Related to #2383

@sdirix sdirix requested a review from lucas-koehler May 28, 2026 14:16
@netlify
Copy link
Copy Markdown

netlify Bot commented May 28, 2026

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 37387f3
🔍 Latest deploy log https://app.netlify.com/projects/jsonforms-examples/deploys/6a1ef525a4c5c700086219bd
😎 Deploy Preview https://deploy-preview-2584--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coveralls
Copy link
Copy Markdown

coveralls commented May 28, 2026

Coverage Status

coverage: 83.776% (+0.7%) from 83.105% — id-generation into master

Copy link
Copy Markdown
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

LGTM thanks!

There might be an edge case where freed ids are not reused:
When an id is freed that had collided with a different prefix's id, the freed low suffix may not be reused, so a later id for that prefix can get a higher number. This can't happen with the JSON-pointer scopes JSON Forms generates ids from.

AS this should not happen and does not violate the expectation of unique ids, there is no need to complicate the current code.

@lucas-koehler lucas-koehler added this to the 3.8 milestone Jun 2, 2026
sdirix added 2 commits June 2, 2026 17:21
Introduces an `Id` object holding `createId`, `removeId` and `clearAllIds`
references and routes all renderer-set callers through it.
Adopters can now swap the default implementations.
`createId` previously rescanned the global id set from index 0 on every
call. With N identical proposed ids this is O(N^2).

Track a per-prefix `next` cursor and a reverse map from id to slot so
the scan starts at the lowest unallocated index. `removeId` reuses
freed slots by rewinding the cursor. All previously observable
behavior is preserved.
@lucas-koehler
Copy link
Copy Markdown
Contributor

@sdirix For transparency: I rebased the commits onto master and changed the wording very slightly replacing chore with core: IMO these changes are changes to the core package and not a simple chore. I'll update the PR title accordingly

@lucas-koehler lucas-koehler changed the title chore: improve id generation core: improve id generation Jun 2, 2026
@lucas-koehler lucas-koehler merged commit 37387f3 into master Jun 2, 2026
11 checks passed
@lucas-koehler lucas-koehler deleted the id-generation branch June 2, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants