File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -484,13 +484,14 @@ static bool ends_with(const std::string & str, const std::string & suffix) {
484484
485485static  size_t  find_partial_stop_string (const  std::string &stop, const  std::string &text) {
486486    if  (!text.empty () && !stop.empty ()) {
487-         auto  it = std::find (stop.rbegin (), stop.rend (), text.back ());
488-         while  (it != stop.rend ()) {
489-             size_t  length = std::distance (it, stop.rend ());
490-             if  (text.length () >= length && 0  == text.compare (text.length () - length, length, stop)) {
491-                 return  text.length () - length;
487+         const  char  text_last_char = text.back ();
488+         for  (int64_t  char_index = stop.size () - 1 ; char_index >= 0 ; char_index--) {
489+             if  (stop[char_index] == text_last_char) {
490+                 const  std::string current_partial = stop.substr (0 , char_index + 1 );
491+                 if  (ends_with (text, current_partial)) {
492+                     return  text.size () - char_index - 1 ;
493+                 }
492494            }
493-             it = std::find (std::next (it), stop.rend (), text.back ());
494495        }
495496    }
496497
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments