Skip to content

Commit 5191147

Browse files
Merge pull request #44 from wowemulation-dev/perf/phase5-vm-optimizations
perf: investigate VM optimization opportunities
2 parents 865cf7f + 0836292 commit 5191147

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/vm/table.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ impl Table {
634634
/// This is the fast path for integer-keyed access. Uses the unsigned
635635
/// trick `(key - 1) as u64 < array_len` to simultaneously check
636636
/// `key >= 1` and `key <= array_len`.
637+
#[inline]
637638
pub fn get_int(&self, key: i64) -> Val {
638639
// Unsigned trick: negative keys and 0 wrap to large values.
639640
let idx = (key as u64).wrapping_sub(1);
@@ -669,6 +670,7 @@ impl Table {
669670
///
670671
/// Uses the string's cached hash for bucket lookup, then compares
671672
/// by `GcRef` identity (interning guarantees unique refs).
673+
#[inline]
672674
pub fn get_str(&self, key: GcRef<LuaString>, strings: &Arena<LuaString>) -> Val {
673675
if self.nodes.is_empty() {
674676
return Val::Nil;
@@ -695,6 +697,7 @@ impl Table {
695697
///
696698
/// For number keys, tries integer fast path first. For string keys,
697699
/// uses pointer-identity comparison. For nil, returns nil immediately.
700+
#[inline]
698701
pub fn get(&self, key: Val, strings: &Arena<LuaString>) -> Val {
699702
match key {
700703
Val::Nil => Val::Nil,
@@ -711,6 +714,7 @@ impl Table {
711714
}
712715

713716
/// Walk the hash chain for a generic key.
717+
#[inline]
714718
fn get_hash(&self, key: Val, strings: &Arena<LuaString>) -> Val {
715719
if self.nodes.is_empty() {
716720
return Val::Nil;
@@ -826,6 +830,7 @@ impl Table {
826830
///
827831
/// Returns `Err` if the key is not found in the table (the table was
828832
/// modified during iteration in a way that invalidated the key).
833+
#[inline]
829834
pub fn next(&self, key: Val, strings: &Arena<LuaString>) -> LuaResult<Option<(Val, Val)>> {
830835
let idx = self.find_index(key, strings)?;
831836

0 commit comments

Comments
 (0)