while (i <= source.used && j <= destination->used) {
- if (!source.string[source.used - i]) {
- ++i;
-
- continue;
- }
-
- if (!destination->string[destination->used - j]) {
- ++j;
-
- continue;
- }
-
if (source.string[source.used - i] != destination->string[destination->used - j]) {
return private_f_string_append(source.string, source.used, destination);
}
return private_f_string_append(source.string + range.start, length, destination);
}
+ const f_array_length_t stop = range.stop >= source.used ? source.used : range.stop + 1;
f_array_length_t i = 1;
f_array_length_t j = 1;
while (i <= length && j <= destination->used) {
- if (!source.string[range.stop - i]) {
- ++i;
-
- continue;
- }
-
- if (!destination->string[destination->used - j]) {
- ++j;
-
- continue;
- }
-
- if (source.string[range.stop - i] != destination->string[destination->used - j]) {
+ if (source.string[stop - i] != destination->string[destination->used - j]) {
return private_f_string_append(source.string + range.start, length, destination);
}
return private_f_string_append_nulless(source.string + range.start, length, destination);
}
+ const f_array_length_t stop = range.stop >= source.used ? source.used : range.stop + 1;
f_array_length_t i = 1;
f_array_length_t j = 1;
while (i <= length && j <= destination->used) {
- if (!source.string[range.stop - i]) {
+ if (!source.string[stop - i]) {
++i;
continue;
continue;
}
- if (source.string[range.stop - i] != destination->string[destination->used - j]) {
+ if (source.string[stop - i] != destination->string[destination->used - j]) {
return private_f_string_append_nulless(source.string + range.start, length, destination);
}
#endif // _di_f_string_dynamic_partial_mash_nulless_
#ifndef _di_f_string_dynamic_partial_mish_
- f_status_t f_string_partial_dynamic_mish(const f_string_static_t glue, const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) {
+ f_status_t f_string_dynamic_partial_mish(const f_string_static_t glue, const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t * const destination) {
#ifndef _di_level_0_parameter_checking_
if (!destination) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
while (i < length && j < destination->used) {
- if (!source.string[i + range.start]) {
- ++i;
-
- continue;
- }
-
- if (!destination->string[j]) {
- ++j;
-
- continue;
- }
-
if (source.string[i + range.start] != destination->string[j]) {
return private_f_string_prepend(source.string + range.start, length, destination);
}
while (i < source.used && j < destination->used) {
- if (!source.string[i]) {
- ++i;
-
- continue;
- }
-
- if (!destination->string[j]) {
- ++j;
-
- continue;
- }
-
if (source.string[i] != destination->string[j]) {
return private_f_string_prepend(source.string, source.used, destination);
}
/**
* Append the source string onto the destination only if the string is not already at the end and restricted to the given range.
*
- * This ignores NULL characters when comparing both the source and the destination.
- *
* @param source
* The source string to append.
* @param range
*
* Prepend operations require memory move operations and are therefore likely more expensive than append operations.
*
- * This ignores NULL characters when comparing both the source and the destination.
- *
* @param source
* The source string to prepend.
* @param range
*
* Prepend operations require memory move operations and are therefore likely more expensive than append operations.
*
- * This ignores NULL characters when comparing both the source and the destination.
- *
* @param source
* The source string to prepend.
* @param destination