pub(crate) fn new_static_bytes(
        &self,
        span: Span,
        current: &[u8],
    ) -> Result<usize, CompileError> {
        let mut inner = self.inner.borrow_mut();

        let hash = Hash::static_bytes(current);

        if let Some(existing_slot) = inner.static_bytes_rev.get(&hash).copied() {
            let existing = inner.static_bytes.get(existing_slot).ok_or_else(|| {
                CompileError::new(
                    span,
                    CompileErrorKind::StaticBytesMissing {
                        hash,
                        slot: existing_slot,
                    },
                )
            })?;

            if &**existing != current {
                return Err(CompileError::new(
                    span,
                    CompileErrorKind::StaticBytesHashConflict {
                        hash,
                        current: current.to_owned(),
                        existing: existing.clone(),
                    },
                ));
            }

            return Ok(existing_slot);
        }

        let new_slot = inner.static_bytes.len();
        inner.static_bytes.push(current.to_owned());
        inner.static_bytes_rev.insert(hash, new_slot);
        Ok(new_slot)
    }
/// Insert a static byte string and return its associated slot that can
/// later be looked up through [lookup_bytes][Unit::lookup_bytes].
///
/// Only uses up space if the static byte string is unique.
Insert a static byte string and return its associated slot that can
later be looked up through [lookup_bytes][Unit::lookup_bytes].

Only uses up space if the static byte string is unique.
Insert a static byte string and return its associated slot that can later be looked up through [ lookup_bytes ] [ Unit :: lookup_bytes ] . Only uses up space if the static byte string is unique .
pub(crate) fn new_static_bytes(
        &self,
        span: Span,
        current: &[u8],
    ) -> Result<usize, CompileError> {
        let mut inner = self.inner.borrow_mut();
        let hash = Hash::static_bytes(current);
        if let Some(existing_slot) = inner.static_bytes_rev.get(&hash).copied() {
            let existing = inner.static_bytes.get(existing_slot).ok_or_else(|| {
                CompileError::new(
                    span,
                    CompileErrorKind::StaticBytesMissing {
                        hash,
                        slot: existing_slot,
                    },
                )
            })?;
            if &**existing != current {
                return Err(CompileError::new(
                    span,
                    CompileErrorKind::StaticBytesHashConflict {
                        hash,
                        current: current.to_owned(),
                        existing: existing.clone(),
                    },
                ));
            }
            return Ok(existing_slot);
        }
        let new_slot = inner.static_bytes.len();
        inner.static_bytes.push(current.to_owned());
        inner.static_bytes_rev.insert(hash, new_slot);
        Ok(new_slot)
    }
pub ( crate ) fn new_static_bytes ( & self , span : Span , current : & [ u8 ] , ) -> Result < usize , CompileError > { let mut inner = self . inner . borrow_mut ( ) ; let hash = Hash :: static_bytes ( current ) ; if let Some ( existing_slot ) = inner . static_bytes_rev . get ( & hash ) . copied ( ) { let existing = inner . static_bytes . get ( existing_slot ) . ok_or_else ( | | { CompileError :: new ( span , CompileErrorKind :: StaticBytesMissing { hash , slot : existing_slot , } , ) } ) ? ; if & * * existing != current { return Err ( CompileError :: new ( span , CompileErrorKind :: StaticBytesHashConflict { hash , current : current . to_owned ( ) , existing : existing . clone ( ) , } , ) ) ; } return Ok ( existing_slot ) ; } let new_slot = inner . static_bytes . len ( ) ; inner . static_bytes . push ( current . to_owned ( ) ) ; inner . static_bytes_rev . insert ( hash , new_slot ) ; Ok ( new_slot ) }
Insert a static byte string and return its associated slot that can
later be looked up through [lookup_bytes][Unit::lookup_bytes].
Insert a static byte string and return its associated slot that can later be looked up through [ lookup_bytes ] [ Unit :: lookup_bytes ] .
&self
span
Span
current
&[u8]
&self
span
Span
current
&[u8]