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

Code before:

      return ext_object_p->u.class_prop.u.value;
    }
  }

  return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Boolean object."));
} /* ecma_builtin_boolean_prototype_object_value_of */

/**
 * 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);

  switch (builtin_routine_id)
  {
    case ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING:
    {
      ecma_value_t value_of_ret = ecma_builtin_boolean_prototype_object_value_of (this_arg);

      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);
    }
    case ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF:
    {
      return ecma_builtin_boolean_prototype_object_value_of (this_arg);
    }
    default:
    {

Review comment (suggestion):
```c
ecma_value_t value_of_ret = ecma_builtin_boolean_prototype_object_value_of (this_arg);

if (id == ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF) return value_of_ret;

perform toString operation.
```

So no switch is needed.

Code after:

      return ext_object_p->u.class_prop.u.value;
    }
  }

  return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Boolean object."));
} /* ecma_builtin_boolean_prototype_object_value_of */

/**
 * 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 */

/**
 * @}
 * @}