forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit78a843f
committed
Improve regex compiler's arc moving/copying logic.
The functions moveins(), copyins(), moveouts(), copyouts() arerequired to preserve the invariant that there are no duplicate arcs inthe regex's NFA. Spencer's original implementation of them was O(N^2)since it checked separately for a match to each source arc. In commit579840c I improved that by adding sort/merge logic to be used ifmore than a few arcs are to be moved/copied. However, I now realizethat that missed a bet. At many call sites, the target state is newlymade and cannot have any existing in-arcs (respectively out-arcs)that could be duplicates. So spending any cycles at all on checkingfor duplicates is wasted effort; in these cases we can just blindlymove/copy all the source arcs. Add code paths to do that.It turns out that for copyins()/copyouts(), *all* the call sites havethis property, making all the "improved" logic in them flat outunreachable. Perhaps we'll need the full capability again someday,so I just #ifdef'd those paths out rather than removing them entirely.In passing, add a few test cases to improve code coverage in thisarea as well as in regc_locale.c/regc_pg_locale.c.Discussion:https://postgr.es/m/810272.1629064063@sss.pgh.pa.us1 parentf576de1 commit78a843f
File tree
5 files changed
+338
-4
lines changed- src
- backend/regex
- test/modules/test_regex
- expected
- sql
5 files changed
+338
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
777 | 777 | | |
778 | 778 | | |
779 | 779 | | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
780 | 784 | | |
781 | 785 | | |
782 | 786 | | |
| |||
785 | 789 | | |
786 | 790 | | |
787 | 791 | | |
788 | | - | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
789 | 804 | | |
790 | 805 | | |
791 | 806 | | |
| |||
869 | 884 | | |
870 | 885 | | |
871 | 886 | | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
872 | 892 | | |
873 | 893 | | |
874 | 894 | | |
875 | 895 | | |
876 | 896 | | |
877 | 897 | | |
878 | 898 | | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
879 | 905 | | |
880 | | - | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
881 | 911 | | |
882 | 912 | | |
883 | 913 | | |
| |||
944 | 974 | | |
945 | 975 | | |
946 | 976 | | |
| 977 | + | |
947 | 978 | | |
948 | 979 | | |
949 | 980 | | |
| |||
1058 | 1089 | | |
1059 | 1090 | | |
1060 | 1091 | | |
1061 | | - | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
1062 | 1104 | | |
1063 | 1105 | | |
1064 | 1106 | | |
| |||
1142 | 1184 | | |
1143 | 1185 | | |
1144 | 1186 | | |
| 1187 | + | |
| 1188 | + | |
1145 | 1189 | | |
1146 | 1190 | | |
1147 | 1191 | | |
1148 | 1192 | | |
1149 | 1193 | | |
1150 | 1194 | | |
1151 | 1195 | | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
1152 | 1202 | | |
1153 | | - | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
1154 | 1208 | | |
1155 | 1209 | | |
1156 | 1210 | | |
| |||
1217 | 1271 | | |
1218 | 1272 | | |
1219 | 1273 | | |
| 1274 | + | |
1220 | 1275 | | |
1221 | 1276 | | |
1222 | 1277 | | |
| |||
1975 | 2030 | | |
1976 | 2031 | | |
1977 | 2032 | | |
| 2033 | + | |
1978 | 2034 | | |
1979 | 2035 | | |
1980 | 2036 | | |
| |||
2001 | 2057 | | |
2002 | 2058 | | |
2003 | 2059 | | |
| 2060 | + | |
2004 | 2061 | | |
2005 | 2062 | | |
2006 | 2063 | | |
| |||
3562 | 3619 | | |
3563 | 3620 | | |
3564 | 3621 | | |
| 3622 | + | |
3565 | 3623 | | |
3566 | 3624 | | |
3567 | 3625 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
937 | 937 | | |
938 | 938 | | |
939 | 939 | | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
940 | 968 | | |
941 | 969 | | |
942 | 970 | | |
| |||
2932 | 2960 | | |
2933 | 2961 | | |
2934 | 2962 | | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
2935 | 2991 | | |
2936 | 2992 | | |
2937 | 2993 | | |
| |||
3850 | 3906 | | |
3851 | 3907 | | |
3852 | 3908 | | |
| 3909 | + | |
| 3910 | + | |
| 3911 | + | |
| 3912 | + | |
| 3913 | + | |
| 3914 | + | |
| 3915 | + | |
| 3916 | + | |
3853 | 3917 | | |
3854 | 3918 | | |
3855 | 3919 | | |
| |||
4926 | 4990 | | |
4927 | 4991 | | |
4928 | 4992 | | |
| 4993 | + | |
| 4994 | + | |
| 4995 | + | |
| 4996 | + | |
| 4997 | + | |
| 4998 | + | |
| 4999 | + | |
| 5000 | + | |
| 5001 | + | |
| 5002 | + | |
| 5003 | + | |
| 5004 | + | |
| 5005 | + | |
| 5006 | + | |
| 5007 | + | |
| 5008 | + | |
| 5009 | + | |
| 5010 | + | |
| 5011 | + | |
| 5012 | + | |
| 5013 | + | |
| 5014 | + | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
| 5023 | + | |
| 5024 | + | |
| 5025 | + | |
| 5026 | + | |
| 5027 | + | |
| 5028 | + | |
| 5029 | + | |
| 5030 | + | |
| 5031 | + | |
| 5032 | + | |
| 5033 | + | |
| 5034 | + | |
| 5035 | + | |
| 5036 | + | |
| 5037 | + | |
| 5038 | + | |
| 5039 | + | |
| 5040 | + | |
| 5041 | + | |
| 5042 | + | |
| 5043 | + | |
| 5044 | + | |
| 5045 | + | |
| 5046 | + | |
| 5047 | + | |
| 5048 | + | |
0 commit comments
Comments
(0)