Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c (C)

Code before:
/**
 * Dispatcher of the built-in's routines
 *
 * @return ecma value
 *         Returned value must be freed with ecma_free_value.
 */
ecma_value_t
ecma_builtin_boolean_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
                                                                               *   identifier */
                                                 ecma_value_t this_arg, /**< 'this' argument value */
                                                 const ecma_value_t arguments_list_p[], /**< list of arguments
                                                                                         *   passed to routine */
                                                 uint32_t arguments_number) /**< length of arguments' list */
{
  JERRY_UNUSED (arguments_number);
  JERRY_UNUSED (arguments_list_p);

  ecma_value_t value_of_ret = ecma_builtin_boolean_prototype_object_value_of (this_arg);
  if (builtin_routine_id == ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF)
  {
    return value_of_ret;
  }

  if (ECMA_IS_VALUE_ERROR (value_of_ret))
  {
    return value_of_ret;
  }

  if (ecma_is_value_true (value_of_ret))
  {
    return ecma_make_magic_string_value (LIT_MAGIC_STRING_TRUE);
  }

  JERRY_ASSERT (ecma_is_value_boolean (value_of_ret));

  return ecma_make_magic_string_value (LIT_MAGIC_STRING_FALSE);
} /* ecma_builtin_boolean_prototype_dispatch_routine */

/**
 * @}
 * @}
 * @}
 */

#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */


Review comment (suggestion):
There should be an assert before this if.
`JERRY_ASSERT (builtin_routine_id == ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING);`


Code after:
/**
 * Dispatcher of the built-in's routines
 *
 * @return ecma value
 *         Returned value must be freed with ecma_free_value.
 */
ecma_value_t
ecma_builtin_boolean_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
                                                                               *   identifier */
                                                 ecma_value_t this_arg, /**< 'this' argument value */
                                                 const ecma_value_t arguments_list_p[], /**< list of arguments
                                                                                         *   passed to routine */
                                                 uint32_t arguments_number) /**< length of arguments' list */
{
  JERRY_UNUSED (arguments_number);
  JERRY_UNUSED (arguments_list_p);

  ecma_value_t value_of_ret = ecma_builtin_boolean_prototype_object_value_of (this_arg);
  if (builtin_routine_id == ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF)
  {
    return value_of_ret;
  }

  JERRY_ASSERT (builtin_routine_id == ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING);

  if (ECMA_IS_VALUE_ERROR (value_of_ret))
  {
    return value_of_ret;
  }

  if (ecma_is_value_true (value_of_ret))
  {
    return ecma_make_magic_string_value (LIT_MAGIC_STRING_TRUE);
  }

  JERRY_ASSERT (ecma_is_value_false (value_of_ret));

  return ecma_make_magic_string_value (LIT_MAGIC_STRING_FALSE);
} /* ecma_builtin_boolean_prototype_dispatch_routine */

/**
 * @}
 * @}
 * @}
 */

#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */