mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Convert Block::event_blocks to a bool
We only increment it and check if it's non-zero, we never decrement or check the actual count. As such, change it to a bool and bring the size of `Block` down from 32 to 24 bytes.
This commit is contained in:
parent
edd6533a14
commit
2e52d51af2
@ -139,7 +139,7 @@ pub fn block(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Op
|
|||||||
};
|
};
|
||||||
|
|
||||||
if have_block {
|
if have_block {
|
||||||
parser.block_at_index_mut(block_idx).unwrap().event_blocks += 1;
|
parser.block_at_index_mut(block_idx).unwrap().event_blocks |= true;
|
||||||
} else {
|
} else {
|
||||||
parser.global_event_blocks.fetch_add(1, Ordering::Relaxed);
|
parser.global_event_blocks.fetch_add(1, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ impl Event {
|
|||||||
/// Test if specified event is blocked.
|
/// Test if specified event is blocked.
|
||||||
fn is_blocked(&self, parser: &Parser) -> bool {
|
fn is_blocked(&self, parser: &Parser) -> bool {
|
||||||
for block in parser.blocks().iter().rev() {
|
for block in parser.blocks().iter().rev() {
|
||||||
if block.event_blocks != 0 {
|
if block.event_blocks {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,9 @@ pub enum BlockData {
|
|||||||
/// block_t represents a block of commands.
|
/// block_t represents a block of commands.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
|
/// Type of block.
|
||||||
|
block_type: BlockType,
|
||||||
|
|
||||||
/// [`BlockType`]-specific data.
|
/// [`BlockType`]-specific data.
|
||||||
///
|
///
|
||||||
/// Ideally this would be coalesced into `BlockType` but we currently require that to implement
|
/// Ideally this would be coalesced into `BlockType` but we currently require that to implement
|
||||||
@ -70,8 +73,8 @@ pub struct Block {
|
|||||||
/// we store them in a `Box` to reduce the size of the `Block` itself.
|
/// we store them in a `Box` to reduce the size of the `Block` itself.
|
||||||
pub data: Option<Box<BlockData>>,
|
pub data: Option<Box<BlockData>>,
|
||||||
|
|
||||||
/// List of event blocks.
|
/// Pseudo-counter of event blocks
|
||||||
pub event_blocks: u64,
|
pub event_blocks: bool,
|
||||||
|
|
||||||
/// Name of the file that created this block
|
/// Name of the file that created this block
|
||||||
pub src_filename: Option<Arc<WString>>,
|
pub src_filename: Option<Arc<WString>>,
|
||||||
@ -84,9 +87,6 @@ pub struct Block {
|
|||||||
/// This will saturate at the 65,535th line of a single fish script. I think that's ok!
|
/// This will saturate at the 65,535th line of a single fish script. I think that's ok!
|
||||||
pub src_lineno: Option<NonZeroU16>,
|
pub src_lineno: Option<NonZeroU16>,
|
||||||
|
|
||||||
/// Type of block.
|
|
||||||
block_type: BlockType,
|
|
||||||
|
|
||||||
/// Whether we should pop the environment variable stack when we're popped off of the block
|
/// Whether we should pop the environment variable stack when we're popped off of the block
|
||||||
/// stack.
|
/// stack.
|
||||||
pub wants_pop_env: bool,
|
pub wants_pop_env: bool,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user