From 35a84769d4dbc0670550ea2abde83bd33dc28729 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sun, 16 Mar 2014 11:34:41 +0100 Subject: 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. --- cores/arduino/WString.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cores/arduino/WString.cpp') 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){ -- cgit v1.2.3-18-g5258