perf: reduce performing of .loc()

This commit is contained in:
Shunsuke Shibayama 2023-02-15 02:33:28 +09:00
parent 5d90029f09
commit 5f6c8a3b2b
9 changed files with 83 additions and 49 deletions

View file

@ -2519,9 +2519,10 @@ impl PyCodeGenerator {
}
fn push_lnotab(&mut self, expr: &Expr) {
if expr.ln_begin().unwrap_or_else(|| panic!("{expr}")) > self.cur_block().prev_lineno {
let ln_begin = expr.ln_begin().unwrap_or_else(|| panic!("{expr}"));
if ln_begin > self.cur_block().prev_lineno {
let sd = self.lasti() - self.cur_block().prev_lasti;
let ld = expr.ln_begin().unwrap() - self.cur_block().prev_lineno;
let ld = ln_begin - self.cur_block().prev_lineno;
if ld != 0 {
if sd != 0 {
self.mut_cur_block_codeobj().lnotab.push(sd as u8);