Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/base/ecma-helpers-string.c (C)

Code before:
    ret_string_p = ecma_new_ecma_string_from_utf8 (utf8_str_p, utf8_str_size);
  }
  else
  {
    ret_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
  }

  if (flags & ECMA_STRING_FLAG_MUST_BE_FREED)
  {
    jmem_heap_free_block ((void *) utf8_str_p, utf8_str_size);
  }

  return ret_string_p;
} /* ecma_string_trim */

#if ENABLED (JERRY_ESNEXT)
/**
 * Pad end or start of string with parameter given in fill_string to the length of max_length.
 *
 * Used by:
 *        - ecma_string_padStart
 *        - ecma_string_padEnd
 * @return new string from original, padded with given parameters
 */
ecma_value_t
ecma_string_stringPad (ecma_value_t original_string_p, /**< Input ecma string */
                       ecma_value_t max_length, /**< Length to pad to, including original length */
                       ecma_value_t fill_string,  /**< The string to pad with*/
                       bool pad_on_start) /**< true - if we are padding to the start, calling with padStart
                                                    false - if we are padding to the end, callind with padEnd */
{

  /* 3 */
  uint32_t int_max_length;
  if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (max_length, &int_max_length)))
  {
    return ECMA_VALUE_ERROR;
  }

  /* 4 */
  ecma_string_t *original_str_val_p = ecma_get_string_from_value (original_string_p);
  const ecma_length_t string_length = ecma_string_get_length (original_str_val_p);
  /* 5 */
  if (int_max_length <= string_length)
  {
    return original_string_p;
  }

  ecma_string_t *filler_p = ecma_get_magic_string (LIT_MAGIC_STRING_SPACE_CHAR);
  /* 6 - 7 */
  if (!ecma_is_value_undefined (fill_string))

Review comment (suggestion):
We use snake case. May be a name `ecma_string_pad` ? The `ecma_string_string_pad` would be a bit strange imho.

Code after:
    ret_string_p = ecma_new_ecma_string_from_utf8 (utf8_str_p, utf8_str_size);
  }
  else
  {
    ret_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
  }

  if (flags & ECMA_STRING_FLAG_MUST_BE_FREED)
  {
    jmem_heap_free_block ((void *) utf8_str_p, utf8_str_size);
  }

  return ret_string_p;
} /* ecma_string_trim */

#if ENABLED (JERRY_ESNEXT)

/**
 * Pad the beginning or the end of string with parameter given in fill_string to the length of max_length.
 *
 * @return new string from original, padded with given parameters
 */
ecma_value_t
ecma_string_pad (ecma_value_t original_string_p, /**< Input ecma string */
                 ecma_value_t max_length, /**< Length to pad to, including original length */
                 ecma_value_t fill_string,  /**< The string to pad with */
                 bool pad_on_start) /**< true - if we are padding to the start, calling with padStart
                                         false - if we are padding to the end, calling with padEnd */
{

  /* 3 */
  uint32_t int_max_length;
  if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (max_length, &int_max_length)))
  {
    return ECMA_VALUE_ERROR;
  }
  /* 4 */
  ecma_string_t *original_str_val_p = ecma_get_string_from_value (original_string_p);
  const uint32_t string_length = ecma_string_get_length (original_str_val_p);
  /* 5 */
  if (int_max_length <= string_length)
  {
    ecma_ref_ecma_string (original_str_val_p);
    return original_string_p;
  }

  ecma_string_t *filler_p = ecma_get_magic_string (LIT_MAGIC_STRING_SPACE_CHAR);
  /* 6 - 7 */
  if (!ecma_is_value_undefined (fill_string))
  {
    filler_p = ecma_op_to_string (fill_string);