File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -780,18 +780,18 @@ export class Series<T extends Scalar = Scalar> {
780780
781781 /** Return a new Series sorted by values. */
782782 sortValues ( ascending = true , naPosition : "first" | "last" = "last" ) : Series < T > {
783- // ── Inline cache check: no method-call overhead on the hot path ──
784- // AL=ascending+last, AF=ascending+first, DL=descending+last, DF=descending+first.
783+ // ── Hot path: read _svCacheAL unconditionally first so the CPU can overlap
784+ // the L1 cache load with branch-condition evaluation (OOO speculation).
785+ // AL=ascending+last (the default call), AF=ascending+first,
786+ // DL=descending+last, DF=descending+first.
787+ const al = this . _svCacheAL ;
788+ if ( al !== null && ascending && naPosition === "last" ) return al ;
785789 if ( ascending ) {
786- const hit = naPosition === "last" ? this . _svCacheAL : this . _svCacheAF ;
787- if ( hit !== null ) {
788- return hit ;
789- }
790+ const af = this . _svCacheAF ;
791+ if ( af !== null ) return af ;
790792 } else {
791793 const hit = naPosition === "last" ? this . _svCacheDL : this . _svCacheDF ;
792- if ( hit !== null ) {
793- return hit ;
794- }
794+ if ( hit !== null ) return hit ;
795795 }
796796 const result = this . _sortValuesColdPath ( ascending , naPosition ) ;
797797 this . _svSetCache ( ascending , naPosition , result ) ;
You can’t perform that action at this time.
0 commit comments