Skip to content

Commit cd40da2

Browse files
committed
Use memcpy instead of character-by-character copying
1 parent 55d2a1b commit cd40da2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ext/standard/html.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -939,13 +939,14 @@ static void traverse_for_entities(
939939
current_ptr = entity_end_ptr + 1;
940940
} else {
941941
/* If the entity is invalid, copy characters from current_ptr up to entity_end_ptr */
942-
if (entity_end_ptr) {
943-
for (; current_ptr < entity_end_ptr; current_ptr++) {
944-
*output_ptr++ = *current_ptr;
945-
}
946-
} else {
947-
*output_ptr++ = *current_ptr++;
948-
}
942+
if (entity_end_ptr) {
943+
size_t len = entity_end_ptr - current_ptr;
944+
memcpy(output_ptr, current_ptr, len);
945+
output_ptr += len;
946+
current_ptr = entity_end_ptr;
947+
} else {
948+
*output_ptr++ = *current_ptr++;
949+
}
949950
}
950951
}
951952

0 commit comments

Comments
 (0)