Skip to content

Commit

Permalink
optimize yy_get_next_buffer by switching to memmove
Browse files Browse the repository at this point in the history
  • Loading branch information
jafl authored and westes committed Apr 27, 2024
1 parent 68eb578 commit b012df9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/c99-flex.skl
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* First move last chars to start of buffer. */
number_to_move = (int) (yyscanner->yy_c_buf_p - yyscanner->yytext_ptr - 1);

for ( i = 0; i < number_to_move; ++i ) {
*(dest++) = *(source++);
}
if (number_to_move > 0)
memmove(dest, source, number_to_move * sizeof(*source));

if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buffer_status == YY_BUFFER_EOF_PENDING ) {
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
Expand Down

0 comments on commit b012df9

Please sign in to comment.