File tree 1 file changed +16
-13
lines changed
1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -114,19 +114,22 @@ auto is_preprocessor(
114
114
auto starts_with_import (std::string const & line)
115
115
-> bool
116
116
{
117
- auto import_first =
118
- std::find_if_not (
119
- line.data (),
120
- line.data ()+line.length (),
121
- [](char c) { return std::isspace (c); }
122
- );
123
- auto import_last =
124
- std::find_if (
125
- import_first,
126
- line.data ()+line.length (),
127
- [](char c) { return std::isspace (c); }
128
- );
129
- return std::string_view{import_first, import_last} == " import" ;
117
+ auto i = 0 ;
118
+
119
+ // find first non-whitespace character
120
+ if (!move_next (line, i, isspace)) {
121
+ return false ;
122
+ }
123
+
124
+ static constexpr auto import_keyword = std::string_view{" import" };
125
+
126
+ // the first token must begin with 'import'
127
+ if (!std::string_view (line).substr (i).starts_with (import_keyword)) {
128
+ return false ;
129
+ }
130
+
131
+ // and not be immediately followed by an _identifier-continue_
132
+ return !is_identifier_continue (line[i + import_keyword.size ()]);
130
133
}
131
134
132
135
You can’t perform that action at this time.
0 commit comments