Skip to content

Commit 8338f98

Browse files
committed
perf: avoid repeated pointer traversals
Supposedly gives us a 0.5% win in CPU time: Summary of cpu time and (wall time): best avg sd +/- p (best) (avg) (sd) +/- p pathological 0.20469 0.21396 0.06910 [-0.5%] (0.20469) (0.21400) (0.06916) [-0.5%] command-t 0.15212 0.15898 0.05456 [+1.4%] (0.15211) (0.15898) (0.05456) [+1.4%] chromium (subset) 1.12325 1.18233 0.08018 [-0.9%] 0.025 (0.25472) (0.27047) (0.02438) [-0.1%] chromium (whole) 0.90673 0.91697 0.05037 [-0.2%] 0.005 (0.10008) (0.10497) (0.01930) [+0.2%] big (400k) 1.38030 1.38569 0.01572 [-0.6%] 0.0005 (0.14990) (0.15333) (0.00925) [-0.8%] total 3.77224 3.85793 0.13443 [-0.5%] 0.005 (0.86813) (0.90174) (0.10183) [-0.0%]
1 parent bc8fe12 commit 8338f98

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lua/wincent/commandt/lib/score.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ static float recursive_match(
3535
) {
3636
float *memoized = NULL;
3737
float seen_score = 0.0f;
38+
const char *haystack_contents = m->haystack->candidate->contents;
3839

3940
// Iterate over needle.
4041
for (size_t i = needle_idx; i < m->needle_length; i++) {
4142
char needle_char = m->needle_p[i];
42-
const char *haystack_contents = m->haystack->candidate->contents;
4343

4444
// Iterate over (valid range of) haystack.
4545
for (size_t j = haystack_idx; j <= m->rightmost_match_p[i]; j++) {

0 commit comments

Comments
 (0)