Skip to content

Commit dac31d3

Browse files
authored
ml-matches: restore fast-path cache update (#36740)
In attempting to add one early-exit path, the cache update had gotten lost for the other fast path!
1 parent 1e6e656 commit dac31d3

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ static void jl_verify_edges(jl_array_t *targets, jl_array_t **pvalids)
18381838
else {
18391839
size_t j, k, l = jl_array_len(expected);
18401840
for (k = 0; k < jl_array_len(matches); k++) {
1841-
jl_method_match_t *match = jl_array_ptr_ref(matches, k);
1841+
jl_method_match_t *match = (jl_method_match_t*)jl_array_ptr_ref(matches, k);
18421842
jl_method_t *m = match->method;
18431843
for (j = 0; j < l; j++) {
18441844
if (m == (jl_method_t*)jl_array_ptr_ref(expected, j))

src/gf.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2700,13 +2700,13 @@ static jl_value_t *ml_matches(jl_methtable_t *mt, int offs,
27002700
// done with many of these values now
27012701
env.match.ti = NULL; env.matc = NULL; env.match.env = NULL; search.env = NULL;
27022702
size_t i, j, len = jl_array_len(env.t);
2703+
jl_method_match_t *minmax = NULL;
2704+
int minmax_ambig = 0;
2705+
int all_subtypes = 1;
27032706
if (len > 1) {
27042707
// first try to pre-process the results to find the most specific result that fully covers the input
27052708
// (since we can do this in linear time, and the rest is O(n^2)
27062709
// - first see if this might even be profitable, given the requested output we need to compute
2707-
jl_method_match_t *minmax = NULL;
2708-
int minmax_ambig = 0;
2709-
int all_subtypes = 1;
27102710
for (i = 0; i < len; i++) {
27112711
jl_method_match_t *matc = (jl_method_match_t*)jl_array_ptr_ref(env.t, i);
27122712
if (matc->fully_covers != FULLY_COVERS) {
@@ -2771,21 +2771,20 @@ static jl_value_t *ml_matches(jl_methtable_t *mt, int offs,
27712771
if (all_subtypes) {
27722772
if (minmax_ambig) {
27732773
if (!include_ambiguous) {
2774-
JL_GC_POP();
2775-
return jl_an_empty_vec_any;
2774+
len = 0;
2775+
env.t = jl_an_empty_vec_any;
27762776
}
27772777
}
27782778
else {
27792779
assert(minmax != NULL);
27802780
jl_array_ptr_set(env.t, 0, minmax);
27812781
jl_array_del_end((jl_array_t*)env.t, len - 1);
2782-
JL_GC_POP();
2783-
if (lim == 0)
2784-
return jl_false;
2785-
return env.t;
2782+
len = 1;
27862783
}
27872784
}
27882785
}
2786+
}
2787+
if (len > 1) {
27892788
// need to partially domsort the graph now into a list
27902789
// (this is an insertion sort attempt)
27912790
// if we have a minmax method, we ignore anything less specific

0 commit comments

Comments
 (0)