Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-bigint.c (C)

Code before:
  if (sign)
  {
    result_value_p->u.bigint_sign_and_size |= ECMA_BIGINT_SIGN;
  }

  *ECMA_BIGINT_GET_DIGITS (result_value_p, 0) = digit;
  return ecma_make_extended_primitive_value (result_value_p, ECMA_TYPE_BIGINT);
} /* ecma_bigint_create_from_digit */

/**
 * Parse a string and create a BigInt value
 *
 * @return ecma BigInt value or a special value allowed by the option flags
 *         Returned value must be freed with ecma_free_value.
 */
ecma_value_t
ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represenation of the BigInt */
                          lit_utf8_size_t size, /**< string size */
                          uint32_t options) /**< ecma_bigint_parse_string_options_t option bits */
{
  ecma_bigint_digit_t radix = 10;
  uint32_t sign = (options & ECMA_BIGINT_PARSE_SET_NEGATIVE) ? ECMA_BIGINT_SIGN : 0;

  const lit_utf8_byte_t *string_end_p = string_p + size;
  const lit_utf8_byte_t *nonws_start_p = ecma_string_trim_front (string_p, string_p + size);
  size = (lit_utf8_size_t) (string_end_p - nonws_start_p);

  if (size >= 3 && nonws_start_p[0] == LIT_CHAR_0)
  {
    if (nonws_start_p[1] == LIT_CHAR_LOWERCASE_X || nonws_start_p[1] == LIT_CHAR_UPPERCASE_X)
    {
      radix = 16;
      nonws_start_p += 2;
      size -= 2;
    }
    else if (nonws_start_p[1] == LIT_CHAR_LOWERCASE_O || nonws_start_p[1] == LIT_CHAR_UPPERCASE_O)
    {
      radix = 8;
      nonws_start_p += 2;
      size -= 2;
    }
    else if (nonws_start_p[1] == LIT_CHAR_LOWERCASE_B || nonws_start_p[1] == LIT_CHAR_UPPERCASE_B)
    {
      radix = 2;
      nonws_start_p += 2;
      size -= 2;
    }
  }
  else if (size >= 2)
  {
    if (nonws_start_p[0] == LIT_CHAR_PLUS)

Review comment (suggestion):
You don't need `nonws_start_p`. Just simply write:
`string_p = ecma_string_trim_front (string_p, string_end_p);`

Code after:
  if (sign)
  {
    result_value_p->u.bigint_sign_and_size |= ECMA_BIGINT_SIGN;
  }

  *ECMA_BIGINT_GET_DIGITS (result_value_p, 0) = digit;
  return ecma_make_extended_primitive_value (result_value_p, ECMA_TYPE_BIGINT);
} /* ecma_bigint_create_from_digit */

/**
 * Parse a string and create a BigInt value
 *
 * @return ecma BigInt value or a special value allowed by the option flags
 *         Returned value must be freed with ecma_free_value.
 */
ecma_value_t
ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represenation of the BigInt */
                          lit_utf8_size_t size, /**< string size */
                          uint32_t options) /**< ecma_bigint_parse_string_options_t option bits */
{
  ecma_bigint_digit_t radix = 10;
  uint32_t sign = (options & ECMA_BIGINT_PARSE_SET_NEGATIVE) ? ECMA_BIGINT_SIGN : 0;

  const lit_utf8_byte_t *string_end_p = string_p + size;
  string_p = ecma_string_trim_front (string_p, string_p + size);
  size = (lit_utf8_size_t) (string_end_p - string_p);

  if (size >= 3 && string_p[0] == LIT_CHAR_0)
  {
    if (string_p[1] == LIT_CHAR_LOWERCASE_X || string_p[1] == LIT_CHAR_UPPERCASE_X)
    {
      radix = 16;
      string_p += 2;
      size -= 2;
    }
    else if (string_p[1] == LIT_CHAR_LOWERCASE_O || string_p[1] == LIT_CHAR_UPPERCASE_O)
    {
      radix = 8;
      string_p += 2;
      size -= 2;
    }
    else if (string_p[1] == LIT_CHAR_LOWERCASE_B || string_p[1] == LIT_CHAR_UPPERCASE_B)
    {
      radix = 2;
      string_p += 2;
      size -= 2;
    }
  }
  else if (size >= 2)
  {
    if (string_p[0] == LIT_CHAR_PLUS)