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

Code before:
  ecma_object_t *shared_array_buffer = ecma_shared_arraybuffer_new_object (length_uint32);
  ECMA_SET_NON_NULL_POINTER (shared_array_buffer->u2.prototype_cp, proto_p);
  ecma_deref_object (proto_p);

  return ecma_make_object_value (shared_array_buffer);
} /* ecma_op_create_shared_arraybuffer_object */

#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */

/**
 * Helper function: check if the target is SharedArrayBuffer
 *
 * See also: ES11 24.1.1.4
 *
 * @return true - if value is a SharedArrayBuffer object
 *         false - otherwise
 */
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_shared_arraybuffer (ecma_value_t target) /**< the target value */
{
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
  return (ecma_is_value_object (target)
          && ecma_object_class_is (ecma_get_object_from_value (target), ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER));
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
  JERRY_UNUSED (target);
  return false;
} /* ecma_is_shared_arraybuffer */

/**
 * Helper function: check if the target is SharedArrayBuffer Object
 *
 * @return true - if value is a SharedArrayBuffer object
 *         false - otherwise
 */
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_shared_arraybuffer_object (ecma_object_t *object_p) /**< the target object */
{
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
  return ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER);
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
  JERRY_UNUSED (object_p);
  return false;
} /* ecma_is_shared_arraybuffer_object */

/**
 * @}
 * @}
 */


Review comment (suggestion):
This should be:
```c
#if ...
  return (ecma_is...
#else /* !... */
  JERRY_UNUSED (...);
  return false;
#endif
```

The `#else` case is explicitly written out. Otherwise if the shared arraybuffers are enabled the code would look like:
```c
return (...)
JERRY_UNUSED (target)
return false;
```
in which the last two lines are dead-code.

Code after:
  ecma_object_t *shared_array_buffer = ecma_shared_arraybuffer_new_object (length_uint32);
  ECMA_SET_NON_NULL_POINTER (shared_array_buffer->u2.prototype_cp, proto_p);
  ecma_deref_object (proto_p);

  return ecma_make_object_value (shared_array_buffer);
} /* ecma_op_create_shared_arraybuffer_object */

#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */

/**
 * Helper function: check if the target is SharedArrayBuffer
 *
 * See also: ES11 24.1.1.4
 *
 * @return true - if value is a SharedArrayBuffer object
 *         false - otherwise
 */
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_shared_arraybuffer (ecma_value_t target) /**< the target value */
{
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
  return (ecma_is_value_object (target)
          && ecma_object_class_is (ecma_get_object_from_value (target), ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER));
#else /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
  JERRY_UNUSED (target);
  return false;
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
} /* ecma_is_shared_arraybuffer */

/**
 * Helper function: check if the target is SharedArrayBuffer Object
 *
 * @return true - if value is a SharedArrayBuffer object
 *         false - otherwise
 */
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_object_is_shared_arraybuffer (ecma_object_t *object_p) /**< the target object */
{
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
  return ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER);
#else /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
  JERRY_UNUSED (object_p);
  return false;
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
} /* ecma_object_is_shared_arraybuffer */

/**
 * @}
 * @}
 */