Commit 44ee3d6
committed
Limit Forward references in Mathtext parser
Comment indicates that limiting forward references is important for
performance, but many more were used than needed.
This is a 75% reduction in forward reference instances.
Many of these are included in the definition of remaining forward
references but do not themselves need to be a forward reference (indeed
only 1 thing in a given cycle actually needs to be such that it can be
referred to prior to its definition)
`auto_delim` is recursively self-referential, and thus _must_ be all on
its own
`placeable` and `accent` form a tight loop, so one of those two needed
to be a forward reference, and placeable was the easiest to keep (and
most likely to be used in another definition that may introduce similar
constraints)
`token` is one of the more generic definitions, that is used in multiple
other definitions.
`required_group` and `optional_group` both caused failed tests when I
tried to make them no longer forward references, has something to do
with how `__call__` works for `Forward` vs `And` objects in pyparsing
(though did not dig too much deeper into it, beyond noticing that the
names in future `required_group("name")` calls still had error messages
that say `"group"`, not their newer names, and that reverting to
`Forward` instances fixed it).
`operatorname` needed to move to avoid using forward references for
`simple`, but does not actually have a cycle.
Otherwise rewrapped some of the definitions to be one line and fixed a
typing error that I noticed when looking into the parsing things.1 parent 060992a commit 44ee3d6
2 files changed
+41
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1817 | 1817 | | |
1818 | 1818 | | |
1819 | 1819 | | |
1820 | | - | |
1821 | | - | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
1822 | 1825 | | |
1823 | 1826 | | |
1824 | 1827 | | |
| |||
1855 | 1858 | | |
1856 | 1859 | | |
1857 | 1860 | | |
1858 | | - | |
1859 | | - | |
| 1861 | + | |
1860 | 1862 | | |
1861 | 1863 | | |
1862 | 1864 | | |
1863 | 1865 | | |
1864 | | - | |
1865 | | - | |
1866 | 1866 | | |
1867 | 1867 | | |
1868 | | - | |
1869 | 1868 | | |
1870 | | - | |
1871 | | - | |
1872 | | - | |
1873 | | - | |
1874 | | - | |
1875 | | - | |
1876 | | - | |
1877 | | - | |
1878 | | - | |
1879 | | - | |
1880 | 1869 | | |
1881 | 1870 | | |
1882 | | - | |
1883 | 1871 | | |
1884 | | - | |
1885 | | - | |
1886 | | - | |
1887 | 1872 | | |
1888 | | - | |
1889 | 1873 | | |
1890 | 1874 | | |
1891 | 1875 | | |
1892 | | - | |
| 1876 | + | |
| 1877 | + | |
1893 | 1878 | | |
1894 | | - | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
1895 | 1882 | | |
1896 | 1883 | | |
1897 | 1884 | | |
1898 | | - | |
1899 | | - | |
1900 | | - | |
| 1885 | + | |
1901 | 1886 | | |
1902 | | - | |
| 1887 | + | |
1903 | 1888 | | |
1904 | | - | |
1905 | | - | |
1906 | | - | |
1907 | | - | |
1908 | | - | |
1909 | | - | |
1910 | | - | |
1911 | | - | |
1912 | | - | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
1913 | 1892 | | |
1914 | | - | |
| 1893 | + | |
1915 | 1894 | | |
1916 | 1895 | | |
1917 | 1896 | | |
| |||
1920 | 1899 | | |
1921 | 1900 | | |
1922 | 1901 | | |
1923 | | - | |
| 1902 | + | |
1924 | 1903 | | |
1925 | 1904 | | |
1926 | 1905 | | |
1927 | 1906 | | |
1928 | | - | |
| 1907 | + | |
1929 | 1908 | | |
1930 | | - | |
| 1909 | + | |
1931 | 1910 | | |
1932 | 1911 | | |
1933 | | - | |
| 1912 | + | |
1934 | 1913 | | |
1935 | 1914 | | |
1936 | 1915 | | |
1937 | | - | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
1938 | 1935 | | |
1939 | 1936 | | |
1940 | 1937 | | |
| |||
1954 | 1951 | | |
1955 | 1952 | | |
1956 | 1953 | | |
1957 | | - | |
1958 | | - | |
1959 | | - | |
1960 | | - | |
1961 | | - | |
1962 | | - | |
1963 | | - | |
1964 | | - | |
1965 | | - | |
1966 | | - | |
1967 | | - | |
1968 | | - | |
1969 | | - | |
1970 | | - | |
1971 | | - | |
1972 | | - | |
1973 | | - | |
1974 | | - | |
1975 | | - | |
1976 | | - | |
1977 | | - | |
1978 | 1954 | | |
1979 | 1955 | | |
1980 | 1956 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
0 commit comments