From 186d2c7cfc995ca88e9df3f149bd42ceacac86bd Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Wed, 27 Aug 2025 23:58:25 -0400 Subject: [PATCH 1/4] Reapply "Skip phase 3 in intersection function" --- src/word-list.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/word-list.c b/src/word-list.c index a88fe93a..0bc3b464 100644 --- a/src/word-list.c +++ b/src/word-list.c @@ -1496,29 +1496,34 @@ word_list_find_intersection (WordList *word_list, * intersections. This is done in three phases. */ - /* Phase 1: Calculate the set of possible characters at pos1 for - * filter1. We don't need to worry about calculating the word_list - * yet */ - charset1 = calculate_intersect_phase1 (word_list, - filter1, pos1, - n_chars1); - - /* phase 2: Calculate the overlapping characters and the second - * word_array. If necessary, calculate the second filters word_array */ - charset2 = + + /* Phase 1: Calculate the set of possible characters at pos2 of + * the second clue, constrained by the second clue's filter. */ + charset2 = calculate_intersect_phase1 (word_list, + filter2, pos2, + n_chars2); + + /* Phase 2: Calculate the set of possible characters at pos1 of + * the first clue, constrained by the first clue's filter, and by + * charset2. If necessary, calculate word_array1. */ + charset1 = calculate_intersect_phase2 (word_list, - filter2, pos2, - n_chars2, - charset1, - word_array2?*word_array2:NULL); - - /* phase 3: Recalculate the word_array first filter with the - * overlap */ - calculate_intersect_phase3 (word_list, - filter1, pos1, - n_chars1, - charset2, - word_array1?*word_array1:NULL); + filter1, pos1, + n_chars1, + charset2, + word_array1?*word_array1:NULL); + + /* Phase 3 (optional): Calculate the set of possible characters at + * pos2 of the second clue, constrained by the second clue's filter, + * and by charset1. Calculate word_array2. */ + if (word_array2 != NULL) + { + calculate_intersect_phase3 (word_list, + filter2, pos2, + n_chars2, + charset1, + *word_array2); + } sort_word_arrays (word_array1, word_array2); -- GitLab From 09c7d14ba5cb58ad7caf1a8c5fa7952d7829d4ab Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Thu, 28 Aug 2025 00:10:22 -0400 Subject: [PATCH 2/4] Fix style --- src/word-list.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/word-list.c b/src/word-list.c index 0bc3b464..f9570f43 100644 --- a/src/word-list.c +++ b/src/word-list.c @@ -1496,11 +1496,11 @@ word_list_find_intersection (WordList *word_list, * intersections. This is done in three phases. */ - /* Phase 1: Calculate the set of possible characters at pos2 of * the second clue, constrained by the second clue's filter. */ charset2 = calculate_intersect_phase1 (word_list, - filter2, pos2, + filter2, + pos2, n_chars2); /* Phase 2: Calculate the set of possible characters at pos1 of @@ -1508,7 +1508,8 @@ word_list_find_intersection (WordList *word_list, * charset2. If necessary, calculate word_array1. */ charset1 = calculate_intersect_phase2 (word_list, - filter1, pos1, + filter1, + pos1, n_chars1, charset2, word_array1?*word_array1:NULL); @@ -1519,7 +1520,8 @@ word_list_find_intersection (WordList *word_list, if (word_array2 != NULL) { calculate_intersect_phase3 (word_list, - filter2, pos2, + filter2, + pos2, n_chars2, charset1, *word_array2); -- GitLab From 6425a849863cc451c37c5c2f0daefd468b0ad049 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Thu, 28 Aug 2025 01:54:00 -0400 Subject: [PATCH 3/4] Fix charset handling --- src/word-list.c | 50 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/word-list.c b/src/word-list.c index f9570f43..a998e02c 100644 --- a/src/word-list.c +++ b/src/word-list.c @@ -1393,8 +1393,8 @@ word_list_find_intersection (WordList *word_list, { guint n_chars1 = 0; guint n_chars2 = 0; - g_autoptr (IpuzCharset) charset1 = NULL; - g_autoptr (IpuzCharset) charset2 = NULL; + g_autoptr (IpuzCharset) charset_incomplete = NULL; + g_autoptr (IpuzCharset) charset_complete = NULL; gboolean filter1_valid = FALSE; gboolean filter2_valid = FALSE; gunichar c1 = 0; @@ -1467,24 +1467,26 @@ word_list_find_intersection (WordList *word_list, { if (filter1_valid) { - charset1 = calculate_intersect_phase2 (word_list, - filter1, pos1, - n_chars1, - NULL, - word_array1?*word_array1:NULL); + charset_complete = + calculate_intersect_phase2 (word_list, + filter1, pos1, + n_chars1, + NULL, + word_array1?*word_array1:NULL); if (intersecting_chars) - *intersecting_chars = ipuz_charset_ref (charset1); + *intersecting_chars = ipuz_charset_ref (charset_complete); sort_word_arrays (word_array1, word_array2); } else if (filter2_valid) { - charset2 = calculate_intersect_phase2 (word_list, - filter2, pos2, - n_chars2, - NULL, - word_array2?*word_array2:NULL); + charset_complete = + calculate_intersect_phase2 (word_list, + filter2, pos2, + n_chars2, + NULL, + word_array2?*word_array2:NULL); if (intersecting_chars) - *intersecting_chars = ipuz_charset_ref (charset2); + *intersecting_chars = ipuz_charset_ref (charset_complete); sort_word_arrays (word_array1, word_array2); } @@ -1498,32 +1500,32 @@ word_list_find_intersection (WordList *word_list, /* Phase 1: Calculate the set of possible characters at pos2 of * the second clue, constrained by the second clue's filter. */ - charset2 = calculate_intersect_phase1 (word_list, - filter2, - pos2, - n_chars2); + charset_incomplete = calculate_intersect_phase1 (word_list, + filter2, + pos2, + n_chars2); /* Phase 2: Calculate the set of possible characters at pos1 of * the first clue, constrained by the first clue's filter, and by - * charset2. If necessary, calculate word_array1. */ - charset1 = + * charset_incomplete. If necessary, calculate word_array1. */ + charset_complete = calculate_intersect_phase2 (word_list, filter1, pos1, n_chars1, - charset2, + charset_incomplete, word_array1?*word_array1:NULL); /* Phase 3 (optional): Calculate the set of possible characters at * pos2 of the second clue, constrained by the second clue's filter, - * and by charset1. Calculate word_array2. */ + * and by charset_complete. Calculate word_array2. */ if (word_array2 != NULL) { calculate_intersect_phase3 (word_list, filter2, pos2, n_chars2, - charset1, + charset_complete, *word_array2); } @@ -1531,7 +1533,7 @@ word_list_find_intersection (WordList *word_list, /* copy our charset over to intersecting_chars */ if (intersecting_chars) - *intersecting_chars = ipuz_charset_ref (charset2); + *intersecting_chars = ipuz_charset_ref (charset_complete); PUSH_TIMER ("word_list_find_intersection()"); } \ No newline at end of file -- GitLab From 28e1ee1ea38b81c21c00b64b34187f3ec93694c0 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Wed, 1 Oct 2025 12:54:44 -0400 Subject: [PATCH 4/4] Fix style --- src/word-list.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/word-list.c b/src/word-list.c index a998e02c..42b99306 100644 --- a/src/word-list.c +++ b/src/word-list.c @@ -1489,14 +1489,12 @@ word_list_find_intersection (WordList *word_list, *intersecting_chars = ipuz_charset_ref (charset_complete); sort_word_arrays (word_array1, word_array2); } - return; } /* Both filter1 and filter2 are valid, so we have to calculate the - * intersections. This is done in three phases. - */ + * intersections. This is done in three phases. */ /* Phase 1: Calculate the set of possible characters at pos2 of * the second clue, constrained by the second clue's filter. */ -- GitLab