Skip to content

Commit

Permalink
YJIT: Initialize Assembler vectors with capacity (ruby#8437)
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Sep 25, 2023
1 parent 98b6b5e commit 750b1a7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions yjit/src/backend/ir.rs
Expand Up @@ -983,6 +983,9 @@ impl SideExitContext {
}
}

/// Initial capacity for asm.insns vector
const ASSEMBLER_INSNS_CAPACITY: usize = 256;

/// Object into which we assemble instructions to be
/// optimized and lowered
pub struct Assembler {
Expand Down Expand Up @@ -1016,8 +1019,8 @@ impl Assembler

pub fn new_with_label_names(label_names: Vec<String>, side_exits: HashMap<SideExitContext, CodePtr>) -> Self {
Self {
insns: Vec::default(),
live_ranges: Vec::default(),
insns: Vec::with_capacity(ASSEMBLER_INSNS_CAPACITY),
live_ranges: Vec::with_capacity(ASSEMBLER_INSNS_CAPACITY),
label_names,
ctx: Context::default(),
side_exits,
Expand Down

0 comments on commit 750b1a7

Please sign in to comment.