(
&mut self,
pending_literal: &mut Option<Wtf8Buf>,
element_count: &mut u32,
keep_empty: bool,
)
| 10029 | } |
| 10030 | |
| 10031 | fn emit_pending_fstring_literal( |
| 10032 | &mut self, |
| 10033 | pending_literal: &mut Option<Wtf8Buf>, |
| 10034 | element_count: &mut u32, |
| 10035 | keep_empty: bool, |
| 10036 | ) { |
| 10037 | let Some(value) = pending_literal.take() else { |
| 10038 | return; |
| 10039 | }; |
| 10040 | |
| 10041 | // CPython drops empty literal fragments when they are adjacent to |
| 10042 | // formatted values, but still emits an empty string for a fully-empty |
| 10043 | // f-string. |
| 10044 | if value.is_empty() && (!keep_empty || *element_count > 0) { |
| 10045 | return; |
| 10046 | } |
| 10047 | |
| 10048 | self.emit_load_const(ConstantData::Str { value }); |
| 10049 | *element_count += 1; |
| 10050 | } |
| 10051 | |
| 10052 | /// Optimize `'format_str' % (args,)` into f-string bytecode. |
| 10053 | /// Returns true if optimization was applied, false to fall back to normal BINARY_OP %. |
no test coverage detected