mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-18 12:54:25 +01:00
Simplify String::remove(unsigned int)
Previously, this method calculated the length of the string from the given index onwards. However, the other remove() method called already contains code for this calculation, which is used when the count passed in is too big. This means we can just pass in a very big count that is guaranteed to point past the end of the string, shrinking the remove method by a few bytes.
This commit is contained in:
parent
2068f88a21
commit
86015f441e
@ -684,8 +684,10 @@ void String::replace(const String& find, const String& replace)
|
||||
}
|
||||
|
||||
void String::remove(unsigned int index){
|
||||
int count = len - index;
|
||||
remove(index, count);
|
||||
// Pass the biggest integer as the count. The remove method
|
||||
// below will take care of truncating it at the end of the
|
||||
// string.
|
||||
remove(index, (unsigned int)-1);
|
||||
}
|
||||
|
||||
void String::remove(unsigned int index, unsigned int count){
|
||||
|
Loading…
x
Reference in New Issue
Block a user