Skip to content
Closed
Changes from 1 commit
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
59 changes: 0 additions & 59 deletions src/url/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
pub mod error;
pub use error::{Error, Result};

use core::cell::RefCell;

use bun_collections::bit_set::{ArrayBitSet, num_masks_for};
use bun_core::{self, fmt as bun_fmt};
use bun_core::{String as BunString, Tag as BunStringTag, strings};
Expand Down Expand Up @@ -375,10 +373,6 @@
Self::from_string(&BunString::borrow_utf8(input))
}

pub fn is_localhost(&self) -> bool {
self.hostname.is_empty() || self.hostname == b"localhost" || self.hostname == b"0.0.0.0"
}

#[inline]
pub fn is_unix(&self) -> bool {
self.protocol.starts_with(b"unix")
Expand Down Expand Up @@ -936,23 +930,9 @@
}
}

thread_local! {
// Unused in current code (commented-out path in get_name_count).
static NAME_COUNT_BUF: RefCell<[*const [u8]; 8]> = const { RefCell::new([std::ptr::from_ref::<[u8]>(&[]); 8]) };
}

impl QueryStringMap {
pub fn get_name_count(&mut self) -> usize {
self.list.len()

Check warning on line 935 in src/url/lib.rs

View check run for this annotation

Claude / Claude Code Review

name_count field is now dead — should be removed alongside the commented-out caching path

The `QueryStringMap.name_count` field (line 903) is now fully orphaned — it's set to `None` at all three construction sites and cloned, but never read anywhere. Since this PR removes `NAME_COUNT_BUF` (which existed for the same commented-out caching path), `name_count` should go too for consistency. Related: `get_name_count()` no longer needs `&mut self` now that the caching write is gone — `&self` suffices.
Comment thread
robobun marked this conversation as resolved.
// if (this.name_count == null) {
// var count: usize = 0;
// var iterate = this.iter();
// while (iterate.next(&_name_count) != null) {
// count += 1;
// }
// this.name_count = count;
// }
// return this.name_count.?;
}

pub fn iter(&self) -> Iterator<'_> {
Expand All @@ -966,45 +946,6 @@
&slice[ptr.offset as usize..ptr.offset as usize + ptr.length as usize]
}

pub fn get_index(&self, input: &[u8]) -> Option<usize> {
let hash = wyhash(input);
self.list.iter().position(|p| p.name_hash == hash)
}

pub fn get(&self, input: &[u8]) -> Option<&[u8]> {
let hash = wyhash(input);
let i = self.list.iter().position(|p| p.name_hash == hash)?;
Some(self.str(self.list[i].value))
}

pub fn has(&self, input: &[u8]) -> bool {
self.get_index(input).is_some()
}

pub fn get_all<'s>(&'s self, input: &[u8], target: &mut [&'s [u8]]) -> usize {
let hash = wyhash(input);
self.get_all_with_hash_from_offset(target, hash, 0)
}

pub fn get_all_with_hash_from_offset<'s>(
&'s self,
target: &mut [&'s [u8]],
hash: u64,
offset: usize,
) -> usize {
let mut remainder = &self.list[offset..];
let mut target_i: usize = 0;
while !remainder.is_empty() && target_i < target.len() {
let Some(i) = remainder.iter().position(|p| p.name_hash == hash) else {
break;
};
target[target_i] = self.str(remainder[i].value);
remainder = &remainder[i + 1..];
target_i += 1;
}
target_i
}

pub fn init_with_scanner(
mut scanner: CombinedScanner<'_>,
) -> Result<Option<QueryStringMap>, bun_alloc::AllocError> {
Expand Down
Loading