mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Issue #14687: Avoid an useless duplicated string in PyUnicode_Format()
This commit is contained in:
		
							parent
							
								
									aff3cc659b
								
							
						
					
					
						commit
						b80e46eca4
					
				
					 1 changed files with 7 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -14051,20 +14051,16 @@ PyUnicode_Format(PyObject *format, PyObject *args)
 | 
			
		|||
                }
 | 
			
		||||
            }
 | 
			
		||||
            /* Copy all characters, preserving len */
 | 
			
		||||
            if (temp != NULL) {
 | 
			
		||||
                assert(pbuf == PyUnicode_DATA(temp));
 | 
			
		||||
                v = PyUnicode_Substring(temp, pindex, pindex + len);
 | 
			
		||||
            if (pindex == 0 && len == PyUnicode_GET_LENGTH(temp)) {
 | 
			
		||||
                r = _PyAccu_Accumulate(&acc, temp);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                const char *p = (const char *) pbuf;
 | 
			
		||||
                assert(pbuf != NULL);
 | 
			
		||||
                p += kind * pindex;
 | 
			
		||||
                v = PyUnicode_FromKindAndData(kind, p, len);
 | 
			
		||||
                v = PyUnicode_Substring(temp, pindex, pindex + len);
 | 
			
		||||
                if (v == NULL)
 | 
			
		||||
                    goto onError;
 | 
			
		||||
                r = _PyAccu_Accumulate(&acc, v);
 | 
			
		||||
                Py_DECREF(v);
 | 
			
		||||
            }
 | 
			
		||||
            if (v == NULL)
 | 
			
		||||
                goto onError;
 | 
			
		||||
            r = _PyAccu_Accumulate(&acc, v);
 | 
			
		||||
            Py_DECREF(v);
 | 
			
		||||
            if (r)
 | 
			
		||||
                goto onError;
 | 
			
		||||
            if (width > len && repeat_accumulate(&acc, blank, width - len))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue