aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2014-03-16 11:34:41 +0100
committerMatthijs Kooijman <matthijs@stdin.nl>2014-09-10 12:33:25 +0200
commit35a84769d4dbc0670550ea2abde83bd33dc28729 (patch)
tree06c78a9e2974530e0fe2b5f6e91ca2df759a566d /cores/arduino
parentb2729a515607f1b0108d38b816430797f558c57f (diff)
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.
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/WString.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp
index e4bed03..f494094 100644
--- a/cores/arduino/WString.cpp
+++ b/cores/arduino/WString.cpp
@@ -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){