LearnNewsExamplesServices
Frontmatter
id8095
titleOptimize Store.initRecord to avoid redundant get() calls
stateClosed
labels
enhancementai
assigneestobiu
createdAtDec 12, 2025, 1:23 PM
updatedAtDec 12, 2025, 1:38 PM
githubUrlhttps://github.com/neomjs/neo/issues/8095
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtDec 12, 2025, 1:38 PM

Optimize Store.initRecord to avoid redundant get() calls

Closed v11.17.0 enhancementai
tobiu
tobiu commented on Dec 12, 2025, 1:23 PM

The add() and insert() methods in Neo.data.Store now default to returning record instances (init=true). This means initRecord() is called more frequently with items that might already be record instances.

Currently, initRecord() calls this.get(), which internally checks if the item is a record. To avoid this unnecessary method call and lookup, we should add an explicit check in initRecord():

initRecord(data) {
    if (RecordFactory.isRecord(data)) {
        return data;
    }
    return this.get(data[this.getKeyProperty()])
}

This optimizes the common path where records are already present.

tobiu added the enhancement label on Dec 12, 2025, 1:23 PM
tobiu added the ai label on Dec 12, 2025, 1:23 PM
tobiu assigned to @tobiu on Dec 12, 2025, 1:24 PM
tobiu referenced in commit 07f24dc - "Optimize Store.initRecord to avoid redundant get() calls #8095" on Dec 12, 2025, 1:37 PM
tobiu closed this issue on Dec 12, 2025, 1:38 PM