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

        let hash = Hash::object_keys(&current[..]);

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

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

            return Ok(existing_slot);
        }

        let new_slot = inner.static_object_keys.len();
        inner.static_object_keys.push(current);
        inner.static_object_keys_rev.insert(hash, new_slot);
        Ok(new_slot)
    }
/// Insert a new collection of static object keys, or return one already
/// existing.
Insert a new collection of static object keys, or return one already
existing.
Insert a new collection of static object keys or return one already existing .
pub(crate) fn new_static_object_keys(
        &self,
        span: Span,
        current: Box<[String]>,
    ) -> Result<usize, CompileError> {
        let mut inner = self.inner.borrow_mut();
        let hash = Hash::object_keys(&current[..]);
        if let Some(existing_slot) = inner.static_object_keys_rev.get(&hash).copied() {
            let existing = inner.static_object_keys.get(existing_slot).ok_or_else(|| {
                CompileError::new(
                    span,
                    CompileErrorKind::StaticObjectKeysMissing {
                        hash,
                        slot: existing_slot,
                    },
                )
            })?;
            if *existing != current {
                return Err(CompileError::new(
                    span,
                    CompileErrorKind::StaticObjectKeysHashConflict {
                        hash,
                        current,
                        existing: existing.clone(),
                    },
                ));
            }
            return Ok(existing_slot);
        }
        let new_slot = inner.static_object_keys.len();
        inner.static_object_keys.push(current);
        inner.static_object_keys_rev.insert(hash, new_slot);
        Ok(new_slot)
    }
pub ( crate ) fn new_static_object_keys ( & self , span : Span , current : Box < [ String ] > , ) -> Result < usize , CompileError > { let mut inner = self . inner . borrow_mut ( ) ; let hash = Hash :: object_keys ( & current [ .. ] ) ; if let Some ( existing_slot ) = inner . static_object_keys_rev . get ( & hash ) . copied ( ) { let existing = inner . static_object_keys . get ( existing_slot ) . ok_or_else ( | | { CompileError :: new ( span , CompileErrorKind :: StaticObjectKeysMissing { hash , slot : existing_slot , } , ) } ) ? ; if * existing != current { return Err ( CompileError :: new ( span , CompileErrorKind :: StaticObjectKeysHashConflict { hash , current , existing : existing . clone ( ) , } , ) ) ; } return Ok ( existing_slot ) ; } let new_slot = inner . static_object_keys . len ( ) ; inner . static_object_keys . push ( current ) ; inner . static_object_keys_rev . insert ( hash , new_slot ) ; Ok ( new_slot ) }
Insert a new collection of static object keys, or return one already
existing.
Insert a new collection of static object keys or return one already existing .
&self
span
Span
current
Box<[String]>
&self
span
Span
current
Box<[String]>