@@ -2331,12 +2331,12 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
23312331 if (context_p -> source_p < context_p -> source_end_p
23322332 && context_p -> source_p [0 ] != LIT_CHAR_COLON )
23332333 {
2334- if (lexer_compare_raw_identifier_to_current (context_p , "get" , 3 ))
2334+ if (lexer_compare_literal_to_string (context_p , "get" , 3 ))
23352335 {
23362336 context_p -> token .type = LEXER_PROPERTY_GETTER ;
23372337 return ;
23382338 }
2339- else if (lexer_compare_raw_identifier_to_current (context_p , "set" , 3 ))
2339+ else if (lexer_compare_literal_to_string (context_p , "set" , 3 ))
23402340 {
23412341 context_p -> token .type = LEXER_PROPERTY_SETTER ;
23422342 return ;
@@ -2345,8 +2345,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
23452345 }
23462346
23472347#if ENABLED (JERRY_ES2015_CLASS )
2348- if (is_class_method
2349- && lexer_compare_raw_identifier_to_current (context_p , "static" , 6 ))
2348+ if (is_class_method && lexer_compare_literal_to_string (context_p , "static" , 6 ))
23502349 {
23512350 context_p -> token .type = LEXER_KEYW_STATIC ;
23522351 return ;
@@ -2406,8 +2405,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
24062405 if (create_literal_object )
24072406 {
24082407#if ENABLED (JERRY_ES2015_CLASS )
2409- if (is_class_method
2410- && lexer_compare_raw_identifier_to_current (context_p , "constructor" , 11 ))
2408+ if (is_class_method && lexer_compare_literal_to_string (context_p , "constructor" , 11 ))
24112409 {
24122410 context_p -> token .type = LEXER_CLASS_CONSTRUCTOR ;
24132411 return ;
@@ -2447,11 +2445,11 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
24472445 if (context_p -> source_p < context_p -> source_end_p
24482446 && context_p -> source_p [0 ] != LIT_CHAR_COLON )
24492447 {
2450- if (lexer_compare_raw_identifier_to_current (context_p , "get" , 3 ))
2448+ if (lexer_compare_literal_to_string (context_p , "get" , 3 ))
24512449 {
24522450 context_p -> token .type = LEXER_PROPERTY_GETTER ;
24532451 }
2454- else if (lexer_compare_raw_identifier_to_current (context_p , "set" , 3 ))
2452+ else if (lexer_compare_literal_to_string (context_p , "set" , 3 ))
24552453 {
24562454 context_p -> token .type = LEXER_PROPERTY_SETTER ;
24572455 }
@@ -2573,27 +2571,46 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< context *
25732571} /* lexer_compare_identifier_to_current */
25742572
25752573/**
2576- * Compares the current identifier in the context to the parameter identifier
2574+ * Compares the current identifier to an expected identifier.
25772575 *
25782576 * Note:
25792577 * Escape sequences are not allowed.
25802578 *
2581- * @return true if the input identifiers are the same
2579+ * @return true if they are the same, false otherwise
25822580 */
2583- bool
2584- lexer_compare_raw_identifier_to_current (parser_context_t * context_p , /**< context */
2585- const char * right_ident_p , /**< identifier */
2586- size_t right_ident_length ) /**< identifier length */
2581+ inline bool JERRY_ATTR_ALWAYS_INLINE
2582+ lexer_compare_literal_to_identifier (parser_context_t * context_p , /**< context */
2583+ const char * identifier_p , /**< identifier */
2584+ size_t identifier_length ) /**< identifier length */
25872585{
2588- lexer_lit_location_t * left_ident_p = & context_p -> token . lit_location ;
2589-
2590- if ( left_ident_p -> length != right_ident_length || left_ident_p -> has_escape )
2591- {
2592- return 0 ;
2593- }
2586+ /* Checking has_escape is unnecessary because memcmp will fail if escape sequences are present. */
2587+ return ( context_p -> token . type == LEXER_LITERAL
2588+ && context_p -> token . lit_location . type == LEXER_IDENT_LITERAL
2589+ && context_p -> token . lit_location . length == identifier_length
2590+ && memcmp ( context_p -> token . lit_location . char_p , identifier_p , identifier_length ) == 0 ) ;
2591+ } /* lexer_compare_literal_to_identifier */
25942592
2595- return memcmp (left_ident_p -> char_p , right_ident_p , right_ident_length ) == 0 ;
2596- } /* lexer_compare_raw_identifier_to_current */
2593+ /**
2594+ * Compares the current identifier or string to an expected string.
2595+ *
2596+ * Note:
2597+ * Escape sequences are not allowed.
2598+ *
2599+ * @return true if they are the same, false otherwise
2600+ */
2601+ inline bool JERRY_ATTR_ALWAYS_INLINE
2602+ lexer_compare_literal_to_string (parser_context_t * context_p , /**< context */
2603+ const char * string_p , /**< string */
2604+ size_t string_length ) /**< string length */
2605+ {
2606+ JERRY_ASSERT (context_p -> token .type == LEXER_LITERAL
2607+ && (context_p -> token .lit_location .type == LEXER_IDENT_LITERAL
2608+ || context_p -> token .lit_location .type == LEXER_STRING_LITERAL ));
2609+
2610+ /* Checking has_escape is unnecessary because memcmp will fail if escape sequences are present. */
2611+ return (context_p -> token .lit_location .length == string_length
2612+ && memcmp (context_p -> token .lit_location .char_p , string_p , string_length ) == 0 );
2613+ } /* lexer_compare_literal_to_string */
25972614
25982615/**
25992616 * Convert binary lvalue token to binary token
0 commit comments