@@ -924,32 +924,31 @@ Standard_OStream& operator << (Standard_OStream& astream,
924924// ----------------------------------------------------------------------------
925925void TCollection_AsciiString::RemoveAll (const Standard_Character what,
926926 const Standard_Boolean CaseSensitive)
927- {
928- if (mylength == 0 ) return ;
929- int c = 0 ;
930- if (CaseSensitive) {
931- for (int i=0 ; i < mylength; i++)
932- if (mystring[i] != what) mystring[c++] = mystring[i];
927+ {
928+ if (mylength == 0 )
929+ {
930+ return ;
933931 }
934- else {
935- Standard_Character upperwhat = ::UpperCase (what);
936- for (int i=0 ; i < mylength; i++) {
937- if (::UpperCase (mystring[i]) != upperwhat) mystring[c++] = mystring[i];
932+ const Standard_Character aTargetChar = CaseSensitive ? what : ::UpperCase (what);
933+ int aNewLength = 0 ;
934+ for (int i = 0 ; i < mylength; ++i)
935+ {
936+ const Standard_Character aCurrentChar = CaseSensitive ? mystring[i] : ::UpperCase (mystring[i]);
937+ if (aCurrentChar != aTargetChar)
938+ {
939+ mystring[aNewLength++] = mystring[i];
938940 }
939941 }
940- mylength = c;
942+ mylength = aNewLength;
943+ mystring[mylength] = ' \0 ' ;
941944}
942945
943946// ----------------------------------------------------------------------------
944947// RemoveAll
945948// ----------------------------------------------------------------------------
946949void TCollection_AsciiString::RemoveAll (const Standard_Character what)
947950{
948- if (mylength == 0 ) return ;
949- int c = 0 ;
950- for (int i=0 ; i < mylength; i++)
951- if (mystring[i] != what) mystring[c++] = mystring[i];
952- mylength = c;
951+ RemoveAll (what, Standard_True);
953952}
954953
955954// ----------------------------------------------------------------------------
0 commit comments