mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
Preallocate output string of str.title() with required size
This commit is contained in:
@@ -425,7 +425,7 @@ impl PyString {
|
|||||||
/// uppercase character and the remaining characters are lowercase.
|
/// uppercase character and the remaining characters are lowercase.
|
||||||
#[pymethod]
|
#[pymethod]
|
||||||
fn title(&self, _vm: &VirtualMachine) -> String {
|
fn title(&self, _vm: &VirtualMachine) -> String {
|
||||||
let mut title = String::new();
|
let mut title = String::with_capacity(self.value.len());
|
||||||
let mut previous_is_cased = false;
|
let mut previous_is_cased = false;
|
||||||
for c in self.value.chars() {
|
for c in self.value.chars() {
|
||||||
if c.is_lowercase() {
|
if c.is_lowercase() {
|
||||||
|
|||||||
Reference in New Issue
Block a user