Skip to content

Commit

Permalink
asiegel/funk-speedup: better algo
Browse files Browse the repository at this point in the history
  • Loading branch information
asiegel-jt committed Dec 20, 2024
1 parent e14080e commit 5b6bbe0
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/funk/fd_funk_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,16 @@ fd_funk_rec_query_global( fd_funk_t * funk,
if( fd_funk_rec_map_private_is_null( ele_idx ) ) break;
fd_funk_rec_t * ele = rec_map + ele_idx;
if( hash == ele->map_hash && FD_LIKELY( fd_funk_rec_key_eq( key, ele->pair.key ) ) ) {
if( best_result == NULL ) {
best_result = ele;
best_txn = fd_funk_txn_map_query( txn_map, ele->pair.xid, NULL );
} else {
for( fd_funk_txn_t const * cur_txn = txn; ; cur_txn = fd_funk_txn_parent( cur_txn, txn_map ) ) {
if( cur_txn == best_txn ) break; /* Shortcut not best case */
if( fd_funk_txn_xid_eq( &cur_txn->xid, ele->pair.xid ) ) {
best_result = ele;
best_txn = cur_txn;
break;
}
for( fd_funk_txn_t const * cur_txn = txn; ; cur_txn = fd_funk_txn_parent( cur_txn, txn_map ) ) {
if( best_result && cur_txn == best_txn ) break; /* Shortcut exit */
if( cur_txn == NULL ?
fd_funk_txn_xid_eq_root( ele->pair.xid ) :
fd_funk_txn_xid_eq( &cur_txn->xid, ele->pair.xid ) ) {
best_result = ele;
best_txn = cur_txn;
break;
}
if( cur_txn == NULL) break;
}
}
cur = &ele->map_next;
Expand Down

0 comments on commit 5b6bbe0

Please sign in to comment.