Skip to content

Commit 92a7df1

Browse files
perf(state): remove fmt.Sprintf within for-loop (#1790)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Adjusted the method for constructing composite keys within the indexing process, which may enhance string matching. - **Improvements** - Simplified string concatenation for composite key creation, potentially improving overall performance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Khanh Hoa <[email protected]>
1 parent 2cd7ded commit 92a7df1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

state/indexer/block/kv/kv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ func (idx *BlockerIndexer) indexEvents(batch ds.Txn, events []abci.Event, typ st
540540
}
541541

542542
// index iff the event specified index:true and it's not a reserved event
543-
compositeKey := fmt.Sprintf("%s.%s", event.Type, string(attr.Key))
543+
compositeKey := event.Type + "." + attr.Key
544544
if compositeKey == types.BlockHeightKey {
545545
return fmt.Errorf("event type and attribute key \"%s\" is reserved; please use a different key", compositeKey)
546546
}

state/txindex/kv/kv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (txi *TxIndex) indexEvents(result *abci.TxResult, hash []byte, store ds.Txn
162162
}
163163

164164
// index if `index: true` is set
165-
compositeTag := fmt.Sprintf("%s.%s", event.Type, string(attr.Key))
165+
compositeTag := event.Type + "." + attr.Key
166166
if attr.GetIndex() {
167167
err := store.Put(txi.ctx, ds.NewKey(keyForEvent(compositeTag, attr.Value, result)), hash)
168168
if err != nil {

0 commit comments

Comments
 (0)