Skip to content

Commit ab04157

Browse files
Fast-path with str.is_ascii()
Co-authored-by: Jeong YunWon <youknowone@users.noreply.github.com>
1 parent 20b86b2 commit ab04157

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

vm/src/stdlib/codecs.rs

+3
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ mod _codecs {
317317

318318
#[pyfunction]
319319
fn ascii_encode(args: EncodeArgs, vm: &VirtualMachine) -> EncodeResult {
320+
if args.s.is_ascii() {
321+
return Ok(args.s.as_bytes());
322+
}
320323
do_codec!(ascii::encode, args, vm)
321324
}
322325

0 commit comments

Comments
 (0)