@@ -552,27 +552,12 @@ ecma_builtin_helper_string_index_normalize (ecma_number_t index, /**< index */
552552 * boolean value
553553 */
554554ecma_value_t
555- ecma_builtin_helper_string_prototype_object_index_of (ecma_value_t this_arg , /**< this argument */
555+ ecma_builtin_helper_string_prototype_object_index_of (ecma_string_t * original_str_p , /**< this argument */
556556 ecma_value_t arg1 , /**< routine's first argument */
557557 ecma_value_t arg2 , /**< routine's second argument */
558558 ecma_string_index_of_mode_t mode ) /**< routine's mode */
559559{
560- /* 1 */
561- if (ECMA_IS_VALUE_ERROR (ecma_op_check_object_coercible (this_arg )))
562- {
563- return ECMA_VALUE_ERROR ;
564- }
565-
566- /* 2 */
567- ecma_value_t to_str_val = ecma_op_to_string (this_arg );
568-
569- if (ECMA_IS_VALUE_ERROR (to_str_val ))
570- {
571- return to_str_val ;
572- }
573-
574- /* 5 (indexOf), 6 (lastIndexOf), 11 (startsWith, includes) */
575- ecma_string_t * original_str_p = ecma_get_string_from_value (to_str_val );
560+ /* 5 (indexOf) -- 6 (lastIndexOf) */
576561 const ecma_length_t original_len = ecma_string_get_length (original_str_p );
577562
578563#if ENABLED (JERRY_ES2015_BUILTIN )
@@ -582,7 +567,6 @@ ecma_builtin_helper_string_prototype_object_index_of (ecma_value_t this_arg, /**
582567 && ecma_object_class_is (ecma_get_object_from_value (arg1 ), LIT_MAGIC_STRING_REGEXP_UL )))
583568 {
584569 JERRY_ASSERT (ECMA_STRING_LAST_INDEX_OF < mode && mode <= ECMA_STRING_ENDS_WITH );
585- ecma_deref_ecma_string (original_str_p );
586570 return ecma_raise_type_error (ECMA_ERR_MSG ("Search string can't be of type: RegExp" ));
587571 }
588572#endif /* ENABLED (JERRY_ES2015_BUILTIN) */
@@ -592,7 +576,6 @@ ecma_builtin_helper_string_prototype_object_index_of (ecma_value_t this_arg, /**
592576
593577 if (ECMA_IS_VALUE_ERROR (search_str_val ))
594578 {
595- ecma_deref_ecma_string (original_str_p );
596579 return search_str_val ;
597580 }
598581
@@ -606,7 +589,6 @@ ecma_builtin_helper_string_prototype_object_index_of (ecma_value_t this_arg, /**
606589 /* 10 (startsWith, includes), 11 (endsWith) */
607590 if (ECMA_IS_VALUE_ERROR (ret_value ))
608591 {
609- ecma_deref_ecma_string (original_str_p );
610592 ecma_deref_ecma_string (search_str_p );
611593 return ret_value ;
612594 }
@@ -692,7 +674,6 @@ ecma_builtin_helper_string_prototype_object_index_of (ecma_value_t this_arg, /**
692674 }
693675
694676 ecma_deref_ecma_string (search_str_p );
695- ecma_deref_ecma_string (original_str_p );
696677
697678 return ret_value ;
698679} /* ecma_builtin_helper_string_prototype_object_index_of */
0 commit comments