Change to not allocate extra String
This commit is contained in:
@ -16,23 +16,16 @@ impl Program {
|
|||||||
pub fn recast(&self, options: &FormatOptions, indentation_level: usize) -> String {
|
pub fn recast(&self, options: &FormatOptions, indentation_level: usize) -> String {
|
||||||
let indentation = options.get_indentation(indentation_level);
|
let indentation = options.get_indentation(indentation_level);
|
||||||
|
|
||||||
let result = self
|
let mut result = self
|
||||||
.shebang
|
.shebang
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|sh| format!("{}\n\n", sh.inner.content))
|
.map(|sh| format!("{}\n\n", sh.inner.content))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let result = if !self.non_code_meta.start_nodes.is_empty() {
|
for start in &self.non_code_meta.start_nodes {
|
||||||
result
|
result.push_str(&start.recast(options, indentation_level));
|
||||||
+ &self
|
}
|
||||||
.non_code_meta
|
let result = result; // Remove mutation.
|
||||||
.start_nodes
|
|
||||||
.iter()
|
|
||||||
.map(|start| start.recast(options, indentation_level))
|
|
||||||
.collect::<String>()
|
|
||||||
} else {
|
|
||||||
result
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = self
|
let result = self
|
||||||
.body
|
.body
|
||||||
|
|||||||
Reference in New Issue
Block a user