diff --git a/tomli/_parser.py b/tomli/_parser.py index 89e81c3..ccd6b92 100644 --- a/tomli/_parser.py +++ b/tomli/_parser.py @@ -584,6 +584,8 @@ def parse_value( # noqa: C901 except IndexError: char = None + # IMPORTANT: order conditions based on speed of checking and likelihood + # Basic strings if char == '"': if src.startswith('"""', pos): @@ -604,6 +606,14 @@ def parse_value( # noqa: C901 if src.startswith("false", pos): return pos + 5, False + # Arrays + if char == "[": + return parse_array(src, pos, parse_float) + + # Inline tables + if char == "{": + return parse_inline_table(src, pos, parse_float) + # Dates and times datetime_match = RE_DATETIME.match(src, pos) if datetime_match: @@ -623,14 +633,6 @@ def parse_value( # noqa: C901 if number_match: return number_match.end(), match_to_number(number_match, parse_float) - # Arrays - if char == "[": - return parse_array(src, pos, parse_float) - - # Inline tables - if char == "{": - return parse_inline_table(src, pos, parse_float) - # Special floats first_three = src[pos : pos + 3] if first_three in {"inf", "nan"}: