@@ -46,6 +46,24 @@ pm_char_is_inline_whitespace(const uint8_t b) {
4646 return (pm_byte_table [b ] & PRISM_CHAR_BIT_INLINE_WHITESPACE ) != 0 ;
4747}
4848
49+ /**
50+ * Returns the number of characters at the start of the string that are inline
51+ * whitespace (space/tab). Scans the byte table directly for use in hot paths.
52+ *
53+ * @param string The string to search.
54+ * @param length The maximum number of characters to search.
55+ * @return The number of characters at the start of the string that are inline
56+ * whitespace.
57+ */
58+ static PRISM_FORCE_INLINE size_t
59+ pm_strspn_inline_whitespace (const uint8_t * string , ptrdiff_t length ) {
60+ if (length <= 0 ) return 0 ;
61+ size_t size = 0 ;
62+ size_t maximum = (size_t ) length ;
63+ while (size < maximum && (pm_byte_table [string [size ]] & PRISM_CHAR_BIT_INLINE_WHITESPACE )) size ++ ;
64+ return size ;
65+ }
66+
4967/**
5068 * Returns the number of characters at the start of the string that are
5169 * whitespace. Disallows searching past the given maximum number of characters.
@@ -73,17 +91,6 @@ size_t pm_strspn_whitespace(const uint8_t *string, ptrdiff_t length);
7391 */
7492size_t pm_strspn_whitespace_newlines (const uint8_t * string , ptrdiff_t length , pm_arena_t * arena , pm_line_offset_list_t * line_offsets , uint32_t start_offset );
7593
76- /**
77- * Returns the number of characters at the start of the string that are inline
78- * whitespace. Disallows searching past the given maximum number of characters.
79- *
80- * @param string The string to search.
81- * @param length The maximum number of characters to search.
82- * @return The number of characters at the start of the string that are inline
83- * whitespace.
84- */
85- size_t pm_strspn_inline_whitespace (const uint8_t * string , ptrdiff_t length );
86-
8794/**
8895 * Returns the number of characters at the start of the string that are decimal
8996 * digits. Disallows searching past the given maximum number of characters.
0 commit comments