jerryscript icon indicating copy to clipboard operation
jerryscript copied to clipboard

Introduce 'ecma_is_value_nullish'

Open LaszloLango opened this issue 1 year ago • 1 comments

ecma_is_value_null and ecma_is_value_undefined is used together in multiple places in the source code. It would nice to have a new ecma_is_value_nullish function to make the code simpler and more readable. e.g:

extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_nullish (ecma_value_t value) /**< ecma value */
{
  return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_NULL) || ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_UNDEFINED);
} /* ecma_is_value_null */

LaszloLango avatar Nov 19 '24 10:11 LaszloLango

Nullish naming can be a little bit confusing, because ECMAScript specification doesn't use this term. There are many places in the spec, where an expression should be checked if it is undefined or null. Maybe the ecma_is_value_null_or_undefined(...) would fit better to the ES spec terms.

ossy-szeged avatar Nov 27 '24 11:11 ossy-szeged