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

Code before:
  {
    string_p = ecma_get_symbol_from_value (value_to_find);
  }

  jmem_cpointer_t symbol_list_cp = JERRY_CONTEXT (symbol_list_first_cp);
  jmem_cpointer_t *empty_cpointer_p = NULL;

  while (symbol_list_cp != JMEM_CP_NULL)
  {
    ecma_lit_storage_item_t *symbol_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
                                                                           symbol_list_cp);

    for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
    {
      if (symbol_list_p->values[i] != JMEM_CP_NULL)
      {
        ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
                                                               symbol_list_p->values[i]);

        if (is_for)
        {
          ecma_value_t symbol_desc = ecma_get_symbol_description (value_p);

          if (ecma_is_value_undefined (symbol_desc))
          {
            return ecma_copy_value (ecma_make_symbol_value (value_p));
          }

          ecma_string_t *symbol_desc_p = ecma_get_string_from_value (symbol_desc);

          if (ecma_compare_ecma_strings (symbol_desc_p, string_p))
          {
            /* The current symbol's descriptor matches with the value_to_find,
               so the value is no longer needed. */
            ecma_deref_ecma_string (string_p);
            return ecma_copy_value (ecma_make_symbol_value (value_p));
          }
        }
        else
        {
          if (string_p == value_p)
          {
            ecma_value_t symbol_desc = ecma_get_symbol_description (string_p);

            if (ecma_is_value_undefined (symbol_desc))
            {
              return symbol_desc;
            }

            ecma_string_t *symbol_desc_p = ecma_get_string_from_value (symbol_desc);
            ecma_ref_ecma_string (symbol_desc_p);

Review comment (suggestion):
```c
ecma_ref_ecma_string (value_p);
return ecma_make_symbol_value (value_p);
```

Code after:
  {
    string_p = ecma_get_symbol_from_value (value_to_find);
  }

  jmem_cpointer_t symbol_list_cp = JERRY_CONTEXT (symbol_list_first_cp);
  jmem_cpointer_t *empty_cpointer_p = NULL;

  while (symbol_list_cp != JMEM_CP_NULL)
  {
    ecma_lit_storage_item_t *symbol_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
                                                                           symbol_list_cp);

    for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
    {
      if (symbol_list_p->values[i] != JMEM_CP_NULL)
      {
        ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
                                                               symbol_list_p->values[i]);

        if (is_for)
        {
          ecma_value_t symbol_desc = ecma_get_symbol_description (value_p);

          if (ecma_is_value_undefined (symbol_desc))
          {
            ecma_ref_ecma_string (value_p);
            return ecma_make_symbol_value (value_p);
          }

          ecma_string_t *symbol_desc_p = ecma_get_string_from_value (symbol_desc);

          if (ecma_compare_ecma_strings (symbol_desc_p, string_p))
          {
            /* The current symbol's descriptor matches with the value_to_find,
               so the value is no longer needed. */
            ecma_deref_ecma_string (string_p);
            return ecma_copy_value (ecma_make_symbol_value (value_p));
          }
        }
        else
        {
          if (string_p == value_p)
          {
            ecma_value_t symbol_desc = ecma_get_symbol_description (string_p);

            if (ecma_is_value_undefined (symbol_desc))
            {
              return symbol_desc;
            }

            ecma_string_t *symbol_desc_p = ecma_get_string_from_value (symbol_desc);