Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/ast/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,6 @@ impl Map {
})
}

pub fn init(source_count: usize) -> Map {
let mut v: NestedList = Vec::with_capacity(source_count);
v.resize_with(source_count, Vec::new);
Map {
symbols_for_source: v,
}
}

// Takes ownership of `list` and boxes it into a one-element NestedList.
// PERF: one extra allocation — profile if needed (single caller is the
// printer one-shot, cold).
Expand Down
8 changes: 0 additions & 8 deletions src/boringssl_sys/boringssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,6 @@ impl GeneralNames {
unsafe { sk_num(self.0.as_ptr().cast::<OPENSSL_STACK>()) }
}

pub fn is_empty(&self) -> bool {
self.len() == 0
}

/// Borrows the `i`th entry; `None` past the end.
pub(crate) fn get(&self, i: usize) -> Option<&GENERAL_NAME> {
if i >= self.len() {
Expand Down Expand Up @@ -1098,10 +1094,6 @@ opaque!(

/// `TLS1_3_VERSION` (`openssl/tls1.h`).
pub const TLS1_3_VERSION: u16 = 0x0304;
/// `X509_V_OK` (`openssl/x509.h`).
pub const X509_V_OK: c_long = 0;
/// `SSL_SESS_CACHE_CLIENT` (`openssl/ssl.h`).
pub const SSL_SESS_CACHE_CLIENT: c_int = 1;

unsafe extern "C" {
pub safe fn TLS_method() -> *const SSL_METHOD;
Expand Down
29 changes: 3 additions & 26 deletions src/bun_alloc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,6 @@ impl Default for Mutex {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AllocError;

impl AllocError {
#[inline]
pub const fn name(self) -> &'static str {
"OutOfMemory"
}
}

impl core::fmt::Display for AllocError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str("OutOfMemory")
Expand Down Expand Up @@ -698,13 +691,6 @@ pub unsafe fn realloc_raw(
Ok(new_ptr.cast::<u8>())
}

/// `mi_usable_size` — actual allocated size for a mimalloc-owned ptr.
#[inline]
pub fn usable_size(ptr: *const u8) -> usize {
// SAFETY: `mi_usable_size` is null-safe (returns 0).
unsafe { mimalloc::mi_usable_size(ptr.cast()) }
}

// ──────────────────────────────────────────────────────────────────────────
// Symbols hoisted DOWN into T0 so higher tiers can re-import without cycles.
// ──────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -1453,7 +1439,7 @@ macro_rules! bss_singleton {

/// Heap-allocate a fresh `T` via mimalloc and run its in-place `init_at` initializer.
///
/// Shared body of the `BSSList`/`BSSStringList`/`BSSMapInner` `init()` shims.
/// Shared body of the `BSSStringList`/`BSSMapInner` `init()` shims.
/// The once-guard is the *caller's* responsibility; use the `bss_*!` macros
/// for the canonical per-monomorphization singleton.
#[doc(hidden)] // Public only for the `bss_singleton!` macro expansion in dependent crates.
Expand Down Expand Up @@ -2020,9 +2006,7 @@ impl<ValueType, const COUNT: usize> BSSList<ValueType, COUNT> {
// Rust cannot define generic statics, so the per-monomorphization storage is
// emitted at the *declare site* via `bss_list! { name: T, N }` (see macro
// below), which owns a `SyncUnsafeCell<MaybeUninit<Self>>` + `Once` and
// calls `init_at` on first access. `init()` is kept for callers that manage
// their own once-guard (e.g. `dir_info::hash_map_instance`); it heap-allocs
// a fresh instance each call.
// calls `init_at` on first access.

/// In-place field initialization into demand-zero storage.
///
Expand All @@ -2048,13 +2032,6 @@ impl<ValueType, const COUNT: usize> BSSList<ValueType, COUNT> {
}
}

/// Heap-allocate and initialize a fresh instance. The once-guard is the
/// *caller's* responsibility — use `bss_list!` for
/// the canonical per-monomorphization singleton.
pub fn init() -> NonNull<Self> {
bss_heap_init(Self::init_at)
}

// Singleton teardown belongs to the `bss_list!` singleton wrapper;
// Drop only frees the heap-allocated head chain.

Expand All @@ -2066,7 +2043,7 @@ impl<ValueType, const COUNT: usize> BSSList<ValueType, COUNT> {
&mut self,
) -> core::result::Result<*mut MaybeUninit<ValueType>, AllocError> {
self.used += 1;
// SAFETY: head is always non-null after init() (points at self.tail or heap block).
// SAFETY: head is always non-null after init_at() (points at self.tail or heap block).
let mut head_ptr = self.head.unwrap();
// Check capacity first, allocate the new block if
// needed, then reserve exactly one slot. Safe under `self.mutex`.
Expand Down
8 changes: 0 additions & 8 deletions src/bun_core/bounded_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ impl<T, const BUFFER_CAPACITY: usize> BoundedArrayAligned<T, BUFFER_CAPACITY> {
// If a non-`Copy` caller
// appears, add a `from_slice_clone` or use `ptr::copy_nonoverlapping`.

/// Return the element at index `i` of the slice.
pub fn get(&self, i: usize) -> T
where
T: Copy,
{
self.const_slice()[i]
}

/// Check that the slice can hold at least `additional_count` items.
pub(crate) fn ensure_unused_capacity(
&self,
Expand Down
11 changes: 0 additions & 11 deletions src/bun_core/external_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ impl<T: ExternalSharedDescriptor> ExternalShared<T> {
self.ptr.as_ptr()
}

/// Alias of [`Self::get`] — provided so call sites that previously used a
/// hand-rolled `NonNull` wrapper (e.g. `AbortSignalRef`) keep compiling.
#[inline]
pub fn as_ptr(&self) -> *mut T {
self.ptr.as_ptr()
}

/// # Safety
/// `raw` must be a valid pointer managed by the external refcount.
pub unsafe fn clone_from_raw(raw: *mut T) -> Self {
Expand Down Expand Up @@ -111,10 +104,6 @@ impl<T: ExternalSharedDescriptor> ExternalSharedOptional<T> {
ptr: NonNull::new(incremented_raw),
}
}

pub fn get(&self) -> Option<*mut T> {
self.ptr.map(|p| p.as_ptr())
}
}

impl<T: ExternalSharedDescriptor> Default for ExternalSharedOptional<T> {
Expand Down
17 changes: 0 additions & 17 deletions src/bun_core/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,6 @@ impl<T> RawSlice<T> {
pub const fn new(s: &[T]) -> Self {
RawSlice(core::ptr::from_ref(s))
}
/// Wrap a raw slice pointer.
///
/// # Safety
/// `p` must either be a (dangling, len 0) empty slice or point to `len`
/// initialized `T` that remain live and stable for the lifetime of every
/// `RawSlice` copied from the result.
#[inline]
pub const unsafe fn from_raw(p: *const [T]) -> Self {
RawSlice(p)
}
#[inline]
pub const fn as_ptr(self) -> *const [T] {
self.0
Expand Down Expand Up @@ -935,13 +925,6 @@ pub fn concat_boxed<T: Copy>(parts: &[&[T]]) -> Box<[T]> {
v.into_boxed_slice()
}

/// Back-compat alias for the original `u8`-only buffer-concat. New code should
/// call [`concat_into`] directly.
#[inline]
pub fn concat<'b>(buf: &'b mut [u8], parts: &[&[u8]]) -> &'b [u8] {
concat_into(buf, parts)
}

/// Tagged-union field projection — `data.file`, `chunk.content.javascript`.
///
/// Consolidates ~20 identical
Expand Down
11 changes: 0 additions & 11 deletions src/bun_core/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1835,17 +1835,6 @@ impl SliceWithUnderlyingString {
}
}

/// `fromUTF8` — wrap a borrowed UTF-8 slice (caller keeps it alive).
#[inline]
pub fn from_utf8(utf8: &[u8]) -> SliceWithUnderlyingString {
SliceWithUnderlyingString {
utf8: ZigStringSlice::from_utf8_never_free(utf8),
underlying: String::DEAD,
#[cfg(debug_assertions)]
did_report_extra_memory_debug: false,
}
}

/// `slice` — the UTF-8 byte view.
#[inline]
pub fn slice(&self) -> &[u8] {
Expand Down
3 changes: 0 additions & 3 deletions src/bun_core/string/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@
//! (`FixedBufferStream`, `BufWriter`, `FmtAdapter`, `DiscardingWriter`) on top,
//! so the existing `bun_io::Write` importers are unaffected.

/// `Result<T>` over `core::fmt::Error` so `?` composes everywhere.
pub type Result<T = ()> = core::result::Result<T, core::fmt::Error>;

pub use crate::io::{IntLe, Write};
44 changes: 1 addition & 43 deletions src/bun_core/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ pub unsafe fn bytes_as_slice_mut<T>(bytes: &mut [u8]) -> &mut [T] {
pub struct Unaligned<T: Copy>(T);

impl<T: Copy> Unaligned<T> {
#[inline(always)]
pub const fn new(value: T) -> Self {
Self(value)
}

#[inline(always)]
pub fn get(self) -> T {
// `self` is by-value (already moved into an aligned local), so a plain
Expand Down Expand Up @@ -601,8 +596,7 @@ macro_rules! opaque_extern {
// `bun_threading::Guarded` / `bun_threading::RwLock` directly.
//
// API parity with the previous `parking_lot` aliases: `const fn new(T)`,
// `.lock()` → guard (no `Result`), `.try_lock()` → `Option`, `.get_mut()`,
// `Default`.
// `.lock()` → guard (no `Result`), `.try_lock()` → `Option`, `Default`.

/// Poison-free `std::sync::Mutex<T>` wrapper. See module note above for why
/// this is not `bun_threading::Guarded<T>`.
Expand Down Expand Up @@ -635,13 +629,6 @@ impl<T> Mutex<T> {
Err(std::sync::TryLockError::WouldBlock) => None,
}
}

#[inline]
pub fn get_mut(&mut self) -> &mut T {
self.0
.get_mut()
.unwrap_or_else(std::sync::PoisonError::into_inner)
}
}

impl<T: Default> Default for Mutex<T> {
Expand Down Expand Up @@ -675,13 +662,6 @@ impl<T> RwLock<T> {
.write()
.unwrap_or_else(std::sync::PoisonError::into_inner)
}

#[inline]
pub fn get_mut(&mut self) -> &mut T {
self.0
.get_mut()
.unwrap_or_else(std::sync::PoisonError::into_inner)
}
}

impl<T: Default> Default for RwLock<T> {
Expand Down Expand Up @@ -3356,12 +3336,6 @@ impl<I: GenericIndexInt, M> GenericIndex<I, M> {
GenericIndexOptional(self.0, core::marker::PhantomData)
}
}
impl<I: GenericIndexInt, M> GenericIndexOptional<I, M> {
#[inline]
pub fn is_some(self) -> bool {
!self.is_none()
}
}

/// `GenericIndex::Optional` — `MAX` is `none`.
#[repr(transparent)]
Expand All @@ -3386,18 +3360,7 @@ impl<I: core::fmt::Debug, M> core::fmt::Debug for GenericIndexOptional<I, M> {
}
}
impl<I: GenericIndexInt, M> GenericIndexOptional<I, M> {
#[inline]
pub fn is_none(self) -> bool {
self.0 == I::NULL_VALUE
}

pub const NONE: Self = Self(I::NULL_VALUE, core::marker::PhantomData);
/// Alias for `unwrap()` matching the local-newtype API that pre-existed in
/// `bun_bundler::output_file::IndexOptional`.
#[inline]
pub fn get(self) -> Option<GenericIndex<I, M>> {
self.unwrap()
}
#[inline]
pub fn unwrap(self) -> Option<GenericIndex<I, M>> {
if self.0 == I::NULL_VALUE {
Expand Down Expand Up @@ -4919,11 +4882,6 @@ impl Timespec {
const NS_PER_S: i64 = crate::time::NS_PER_S as i64;
const NS_PER_MS: i64 = crate::time::NS_PER_MS as i64;

#[inline]
pub const fn new(sec: i64, nsec: i64) -> Self {
Self { sec, nsec }
}

#[inline]
pub fn eql(&self, other: &Timespec) -> bool {
self == other
Expand Down
6 changes: 0 additions & 6 deletions src/cares_sys/c_ares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,6 @@ pub struct AddrInfo_hints {
// SAFETY: four `c_int` fields; all-zero is a valid hints value (S021).
unsafe impl bun_core::ffi::Zeroable for AddrInfo_hints {}

impl AddrInfo_hints {
pub fn is_empty(&self) -> bool {
self.ai_flags == 0 && self.ai_family == 0 && self.ai_socktype == 0 && self.ai_protocol == 0
}
}

#[derive(Copy, Clone, Default)]
pub struct ChannelOptions {
pub timeout: Option<i32>,
Expand Down
19 changes: 1 addition & 18 deletions src/css/css_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,6 @@ pub trait QualifiedRuleParser {
#[derive(Default, Clone, Copy, crate::DeepClone)]
pub struct DefaultAtRule;

impl DefaultAtRule {
pub fn to_css(self, dest: &mut Printer) -> Result<(), PrintErr> {
dest.new_error(PrinterErrorKind::fmt_error, None)
}
}

/// Same as `AtRuleParser` but modified to provide parser options.
/// Also added: `on_import_rule` to handle `@import` rules.
pub trait CustomAtRuleParser {
Expand Down Expand Up @@ -5257,11 +5251,6 @@ pub enum TokenKind {
pub use crate::Token;

impl Token {
pub fn eql(lhs: &Token, rhs: &Token) -> bool {
// TODO: derive PartialEq once payload lifetimes settle.
generic::implement_eql(lhs, rhs)
}

/// Return whether this token represents a parse error.
pub(crate) fn is_parse_error(&self) -> bool {
matches!(
Expand Down Expand Up @@ -5506,22 +5495,16 @@ pub use bun_io::Write as WriteAll;
// Num/Dimension data layouts hoisted at crate root (lib.rs).
pub use crate::{Dimension, Num};

// Num/Dimension eql/hash gated until generics::CssEql/CssHash blanket impls
// Num/Dimension hash gated until generics::CssHash blanket impls
// cover the float/slice payloads.

impl Num {
pub fn eql(lhs: &Num, rhs: &Num) -> bool {
generic::implement_eql(lhs, rhs)
}
pub(crate) fn hash(&self, hasher: &mut bun_wyhash::Wyhash) {
generic::implement_hash(self, hasher)
}
}

impl Dimension {
pub fn eql(lhs: &Self, rhs: &Self) -> bool {
generic::implement_eql(lhs, rhs)
}
pub(crate) fn hash(&self, hasher: &mut bun_wyhash::Wyhash) {
generic::implement_hash(self, hasher)
}
Expand Down
10 changes: 0 additions & 10 deletions src/css/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ pub trait CssEql {
/// derive into scope (same-name idiom, cf. `Clone`).
pub use bun_css_derive::CssEql;

#[inline]
pub fn implement_eql<T: CssEql>(this: &T, other: &T) -> bool {
this.eql(other)
}

#[inline]
pub(crate) fn eql<T: CssEql>(lhs: &T, rhs: &T) -> bool {
lhs.eql(rhs)
Expand Down Expand Up @@ -1205,11 +1200,6 @@ pub fn parse_with_options<T: ParseWithOptions>(
T::parse_with_options(input, options)
}

#[inline]
pub fn parse<T: Parse>(input: &mut Parser) -> CssResult<T> {
T::parse(input)
}

// ── container / primitive Parse impls ────────────────────────────────────────

impl<T: Parse> Parse for Option<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/css/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ pub struct Dimension {
}

/// CSS lexer token. Data-only definition hoisted out of `css_parser.rs`; the
/// `to_css*`/`eql`/`hash` impls stay in `css_parser.rs` since they depend on
/// `to_css*`/`hash` impls stay in `css_parser.rs` since they depend on
/// `serializer::*` and `generics`.
// Every `&'static [u8]` payload actually borrows the parser arena/source text and
// must not outlive the arena; `&'static` is the crate-wide placeholder until the
Expand Down
Loading