Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d869035

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

File tree

Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed

‎vm/src/stdlib/codecs.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/codecs.rs
+3Lines changed: 3 additions & 0 deletions
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_str().as_bytes().to_vec(), args.s.byte_len()));
322+
}
320323
do_codec!(ascii::encode, args, vm)
321324
}
322325

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.