1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

perf: use optimization options for Rust and gcc

This commit is contained in:
Divlo
2022-09-24 22:17:07 +02:00
parent 5e5a248238
commit df539a41c0
6 changed files with 8 additions and 8 deletions

View File

@ -10,7 +10,7 @@ int main() {
size_t string_length = strlen(string);
char* result = malloc(sizeof(char*) * (string_length + 1));
for (size_t index = 0; index < string_length; index++) {
size_t number_of_appearances = 0;
unsigned char number_of_appearances = 0;
char value_to_search = string[index];
size_t iteration = index;
while (iteration < string_length && string[iteration] == value_to_search) {
@ -18,7 +18,7 @@ int main() {
iteration++;
}
char* number_of_appearances_string = malloc(sizeof(char*) * (string_length + 1));
snprintf(number_of_appearances_string, sizeof(result), "%zu", number_of_appearances);
snprintf(number_of_appearances_string, sizeof(result), "%hhu", number_of_appearances);
character_append_many(result, number_of_appearances_string);
character_append(result, value_to_search);
index += number_of_appearances - 1;