diff --git a/src/Strings.cc b/src/Strings.cc index 74d2e32..245a102 100644 --- a/src/Strings.cc +++ b/src/Strings.cc @@ -1425,24 +1425,27 @@ T_String T_String::trim( ) const noexcept return T_String( ); } - T_Optional< uint32_t > firstNws; + bool hasFirst = false; + uint32_t firstNws = 0; uint32_t lastNws = 0; T_StringIterator it( *this ); while ( !it.atEnd( ) ) { T_Character c( it ); if ( !c.isWhitespace( ) ) { - if ( !firstNws ) { + if ( !hasFirst ) { firstNws = it.index( ); + hasFirst = true; } lastNws = it.index( ); } it.next( ); } - if ( !firstNws ) { + if ( hasFirst ) { + return range( firstNws , lastNws ); + } else { return T_String( ); } - return range( *firstNws , lastNws ); } /*----------------------------------------------------------------------------*/