Repository: swc-project/swc
File: crates/swc_ecma_parser/src/lexer/token.rs (Rust)

Code before:
        self == Token::Str
            && if let Some(TokenValue::Str { raw, .. }) = buffer.get_token_value() {
                raw == content
            } else {
                unreachable!()
            }
    }

    #[inline(always)]
    pub fn take_str<I: Tokens>(self, buffer: &mut Buffer<I>) -> (Wtf8Atom, Atom) {
        buffer.expect_string_token_value()
    }

    #[inline(always)]
    pub fn take_num<I: Tokens>(self, buffer: &mut Buffer<I>) -> (f64, Atom) {
        buffer.expect_number_token_value()
    }

    #[inline(always)]
    pub fn take_bigint<I: Tokens>(self, buffer: &mut Buffer<I>) -> (Box<BigInt>, Atom) {
        buffer.expect_bigint_token_value()
    }

    #[inline]
    pub fn take_word<I: Tokens>(self, buffer: &Buffer<I>) -> Atom {
        if buffer.cur() == Token::Ident {
            let value = buffer.get_token_value();
            let Some(TokenValue::Word(word)) = value else {
                unreachable!("{:#?}", value)
            };
            return word.clone();
        }

        let span = buffer.cur.span;
        let atom = Atom::new(buffer.iter.read_string(span));
        atom
    }

    #[inline(always)]
    pub fn take_known_ident(self) -> Atom {
        self.as_known_ident_atom().unwrap()
    }

    #[inline(always)]
    pub fn take_unknown_ident_ref<'b, I: Tokens>(&'b self, buffer: &'b Buffer<I>) -> &'b Atom {
        buffer.expect_word_token_value_ref()
    }

    #[inline(always)]
    pub fn take_template<I: Tokens>(self, buffer: &mut Buffer<I>) -> (LexResult<Wtf8Atom>, Atom) {
        buffer.expect_template_token_value()

Review comment (suggestion):
The check should be `if self == Token::Ident` instead of `if buffer.cur() == Token::Ident`. The parameter `self` is the token being examined (from call sites like `cur.take_word(buffer)`), so it should check `self` directly rather than re-querying the buffer's current token.
```suggestion
        if self == Token::Ident {
```

Code after:
        self == Token::Str
            && if let Some(TokenValue::Str { raw, .. }) = buffer.get_token_value() {
                raw == content
            } else {
                unreachable!()
            }
    }

    #[inline(always)]
    pub fn take_str<I: Tokens>(self, buffer: &mut Buffer<I>) -> (Wtf8Atom, Atom) {
        buffer.expect_string_token_value()
    }

    #[inline(always)]
    pub fn take_num<I: Tokens>(self, buffer: &mut Buffer<I>) -> (f64, Atom) {
        buffer.expect_number_token_value()
    }

    #[inline(always)]
    pub fn take_bigint<I: Tokens>(self, buffer: &mut Buffer<I>) -> (Box<BigInt>, Atom) {
        buffer.expect_bigint_token_value()
    }

    #[inline]
    pub fn take_word<I: Tokens>(self, buffer: &Buffer<I>) -> Atom {
        if self == Token::Ident {
            let value = buffer.get_token_value();
            let Some(TokenValue::Word(word)) = value else {
                unreachable!("{:#?}", value)
            };
            return word.clone();
        }

        let span = buffer.cur.span;
        let atom = Atom::new(buffer.iter.read_string(span));
        atom
    }

    #[inline(always)]
    pub fn take_known_ident<I: Tokens>(self, buffer: &Buffer<I>) -> Atom {
        let span = buffer.cur.span;
        let atom = Atom::new(buffer.iter.read_string(span));
        atom
    }

    #[inline(always)]
    pub fn take_unknown_ident_ref<'b, I: Tokens>(&'b self, buffer: &'b Buffer<I>) -> &'b Atom {
        buffer.expect_word_token_value_ref()
    }

    #[inline(always)]