Use string methods for copying bytes, not loops
This commit is contained in:
parent
43f84098b8
commit
5def8f2a86
|
@ -32,9 +32,8 @@ struct Scanner {
|
||||||
|
|
||||||
if (tag.type == CUSTOM) {
|
if (tag.type == CUSTOM) {
|
||||||
buffer[i++] = tag.custom_tag_name.size();
|
buffer[i++] = tag.custom_tag_name.size();
|
||||||
for (char c : tag.custom_tag_name) {
|
tag.custom_tag_name.copy(&buffer[i], tag.custom_tag_name.size());
|
||||||
buffer[i++] = c;
|
i += tag.custom_tag_name.size();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,10 +48,9 @@ struct Scanner {
|
||||||
Tag tag { static_cast<TagType>(buffer[i]), "" };
|
Tag tag { static_cast<TagType>(buffer[i]), "" };
|
||||||
i++;
|
i++;
|
||||||
if (tag.type == CUSTOM) {
|
if (tag.type == CUSTOM) {
|
||||||
tag.custom_tag_name.resize(buffer[i++]);
|
unsigned length = buffer[i++];
|
||||||
for (unsigned j = 0; j < tag.custom_tag_name.size(); j++) {
|
tag.custom_tag_name.assign(&buffer[i], &buffer[i + length]);
|
||||||
tag.custom_tag_name[j] = buffer[i++];
|
i += length;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tags.push_back(tag);
|
tags.push_back(tag);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue