Skip to content

Commit

Permalink
docs(semantic): fix and reformat doc comments (#8652)
Browse files Browse the repository at this point in the history
Update doc comment for `TempUnresolvedReferences` which was out of date. Reformat other comments.
  • Loading branch information
overlookmotel committed Jan 22, 2025
1 parent 9953ac7 commit 5029547
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions crates/oxc_semantic/src/unresolved_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use rustc_hash::FxHashMap;
use oxc_span::Atom;
use oxc_syntax::reference::ReferenceId;

/// The difference with Scope's `UnresolvedReferences` is that this type uses Atom as the key. its clone is very cheap!
/// Unlike `ScopeTree`'s `UnresolvedReferences`, this type uses `Atom` as the key,
/// and uses a heap-allocated hashmap (not arena-allocated)
type TempUnresolvedReferences<'a> = FxHashMap<Atom<'a>, Vec<ReferenceId>>;

// Stack used to accumulate unresolved refs while traversing scopes.
Expand All @@ -21,16 +22,19 @@ pub(crate) struct UnresolvedReferencesStack<'a> {
}

impl<'a> UnresolvedReferencesStack<'a> {
// Initial scope depth.
// Start on 1 (`Program` scope depth).
// SAFETY: Must be >= 1 to ensure soundness of `current_and_parent_mut`.
/// Initial scope depth.
/// Start on 1 (`Program` scope depth).
/// SAFETY: Must be >= 1 to ensure soundness of `current_and_parent_mut`.
const INITIAL_DEPTH: usize = 1;
// Most programs will have at least 1 place where scope depth reaches 16,
// so initialize `stack` with this length, to reduce reallocations as it grows.
// This is just an estimate of a good initial size, but certainly better than
// `Vec`'s default initial capacity of 4.
// SAFETY: Must be >= 2 to ensure soundness of `current_and_parent_mut`.

/// Most programs will have at least 1 place where scope depth reaches 16,
/// so initialize `stack` with this length, to reduce reallocations as it grows.
/// This is just an estimate of a good initial size, but certainly better than
/// `Vec`'s default initial capacity of 4.
/// SAFETY: Must be >= 2 to ensure soundness of `current_and_parent_mut`.
const INITIAL_SIZE: usize = 16;

/// Assert invariant
#[allow(clippy::assertions_on_constants)]
const _SIZE_CHECK: () = assert!(Self::INITIAL_SIZE > Self::INITIAL_DEPTH);

Expand Down

0 comments on commit 5029547

Please sign in to comment.