Skip to content

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Mar 13, 2025

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.

Copy link
Member Author

Dunqing commented Mar 13, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 13, 2025

CodSpeed Instrumentation Performance Report

Merging #9752 will not alter performance

Comparing 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation (6a8c2fd) with main (07f2a25)

Summary

✅ 33 untouched benchmarks

@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec_remove_manuallydrop_wrapper branch from e5a1a8e to d1e11c1 Compare March 14, 2025 06:11
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from 79011fe to 6d4c646 Compare March 14, 2025 06:11
@graphite-app graphite-app bot force-pushed the 03-13-feat_allocator_vec_remove_manuallydrop_wrapper branch from d1e11c1 to 7403cdf Compare March 14, 2025 06:22
@graphite-app graphite-app bot force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from 6d4c646 to 2dae0c0 Compare March 14, 2025 06:22
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from 2dae0c0 to 811cd9a Compare March 14, 2025 06:24
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec_remove_manuallydrop_wrapper branch from 7403cdf to 3812849 Compare March 14, 2025 06:24
Copy link
Member

@overlookmotel overlookmotel left a 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:

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.

@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec_remove_manuallydrop_wrapper branch from 3812849 to cc06e07 Compare March 14, 2025 07:44
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from 811cd9a to 6ab3618 Compare March 14, 2025 07:44
@Dunqing
Copy link
Member Author

Dunqing commented Mar 14, 2025

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:

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.

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.

@Dunqing Dunqing marked this pull request as ready for review March 14, 2025 07:51
@graphite-app graphite-app bot changed the base branch from 03-13-feat_allocator_vec_remove_manuallydrop_wrapper to graphite-base/9752 March 14, 2025 07:59
@graphite-app graphite-app bot force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from 6ab3618 to a85ded2 Compare March 14, 2025 08:06
@graphite-app graphite-app bot force-pushed the graphite-base/9752 branch from cc06e07 to caa477c Compare March 14, 2025 08:06
@graphite-app graphite-app bot changed the base branch from graphite-base/9752 to main March 14, 2025 08:07
@graphite-app graphite-app bot force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from a85ded2 to e194ab0 Compare March 14, 2025 08:07
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from e194ab0 to 87ad9b8 Compare March 18, 2025 07:21
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from 0d9b2d1 to 87ad9b8 Compare March 18, 2025 08:35
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from 87ad9b8 to edee838 Compare March 18, 2025 08:59
@Dunqing Dunqing force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from edee838 to 88a605a Compare March 21, 2025 08:44
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Mar 25, 2025
Copy link
Member

overlookmotel commented Mar 25, 2025

Merge activity

  • Mar 25, 10:05 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 25, 10:05 AM EDT: A user added this pull request to the Graphite merge queue.
  • Mar 25, 2:08 PM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Test (ubuntu-latest)', 'Test (macos-latest)').
  • Mar 25, 10:19 AM EDT: The merge label '0-merge' was removed. This PR will no longer be merged by the Graphite merge queue
  • Mar 25, 10:20 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 25, 10:28 AM EDT: A user added this pull request to the Graphite merge queue.
  • Mar 25, 10:28 AM EDT: A user merged this pull request with the Graphite merge queue.

graphite-app bot pushed a commit that referenced this pull request Mar 25, 2025
…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.~~
@graphite-app graphite-app bot force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from 88a605a to 3514413 Compare March 25, 2025 14:06
@graphite-app graphite-app bot added 0-merge Merge with Graphite Merge Queue and removed 0-merge Merge with Graphite Merge Queue labels Mar 25, 2025
…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.~~
@overlookmotel overlookmotel force-pushed the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch from 3514413 to 6a8c2fd Compare March 25, 2025 14:18
@overlookmotel overlookmotel added 0-merge Merge with Graphite Merge Queue and removed 0-merge Merge with Graphite Merge Queue labels Mar 25, 2025
@graphite-app graphite-app bot merged commit 6a8c2fd into main Mar 25, 2025
29 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 25, 2025
@graphite-app graphite-app bot deleted the 03-13-feat_allocator_vec2_align_the_retain_method_with_the_standard_implementation branch March 25, 2025 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants