-
-
Notifications
You must be signed in to change notification settings - Fork 775
feat(allocator/vec2): align the retain method with the standard implementation
#9752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(allocator/vec2): align the retain method with the standard implementation
#9752
Conversation
CodSpeed Instrumentation Performance ReportMerging #9752 will not alter performanceComparing Summary
|
e5a1a8e to
d1e11c1
Compare
79011fe to
6d4c646
Compare
d1e11c1 to
7403cdf
Compare
6d4c646 to
2dae0c0
Compare
2dae0c0 to
811cd9a
Compare
7403cdf to
3812849
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to remove drain_filter? It looks quite useful. e.g.:
// Move all statements except `import`s and `export`s into a nested `BlockStatement`
let stmts_to_move = program.body.drain_filter(|stmt| stmt.is_module_declaration());
let stmts_to_move = Vec::from_iter_in(stmts_to_move, ast.allocator);
program.body.push(ast.statement_block(SPAN, stmts_to_move));This could make e.g. using transform more efficient:
oxc/crates/oxc_transformer/src/proposals/explicit_resource_management.rs
Lines 218 to 232 in d13817e
| let program_body = ctx.ast.move_vec(&mut program.body); | |
| let (mut program_body, inner_block): ( | |
| ArenaVec<'a, Statement<'a>>, | |
| ArenaVec<'a, Statement<'a>>, | |
| ) = program_body.into_iter().fold( | |
| (ctx.ast.vec(), ctx.ast.vec()), | |
| |(mut program_body, mut inner_block), mut stmt| { | |
| let address = stmt.address(); | |
| match stmt { | |
| Statement::FunctionDeclaration(_) | |
| | Statement::ImportDeclaration(_) | |
| | Statement::ExportAllDeclaration(_) => { | |
| program_body.push(stmt); | |
| } |
But if you want to remove it now, and we add it (or something like it) back again later, I'm fine with that.
3812849 to
cc06e07
Compare
811cd9a to
6ab3618
Compare
Thank you for bringing this example up. I've checked the std library doesn't include this method, and doesn't remember where a case in our codebase can use this method, so I think it can be removed. Now considering there is a case that can benefit from this method, I will keep it. |
6ab3618 to
a85ded2
Compare
cc06e07 to
caa477c
Compare
a85ded2 to
e194ab0
Compare
e194ab0 to
87ad9b8
Compare
0d9b2d1 to
87ad9b8
Compare
87ad9b8 to
edee838
Compare
edee838 to
88a605a
Compare
Merge activity
|
…lementation (#9752) The documentation and the implementation are copied from https://doc.rust-lang.org/src/alloc/vec/mod.rs.html#2095-209. ~~After this change, `drain_filter` is no longer needed, so remove it.~~
88a605a to
3514413
Compare
…lementation (#9752) The documentation and the implementation are copied from https://doc.rust-lang.org/src/alloc/vec/mod.rs.html#2095-209. ~~After this change, `drain_filter` is no longer needed, so remove it.~~
3514413 to
6a8c2fd
Compare

The documentation and the implementation are copied from https://doc.rust-lang.org/src/alloc/vec/mod.rs.html#2095-209.
After this change,drain_filteris no longer needed, so remove it.