include/prism/util/pm_constant_pool.h in prism-0.13.0 vs include/prism/util/pm_constant_pool.h in prism-0.14.0

- old
+ new

@@ -61,9 +61,14 @@ #define PM_CONSTANT_POOL_EMPTY ((pm_constant_pool_t) { .buckets = NULL, .constants = NULL, .size = 0, .capacity = 0 }) // Initialize a new constant pool with a given capacity. bool pm_constant_pool_init(pm_constant_pool_t *pool, uint32_t capacity); +static inline pm_constant_t* pm_constant_pool_id_to_constant(pm_constant_pool_t *pool, pm_constant_id_t constant_id) { + assert(constant_id > 0 && constant_id <= pool->size); + return &pool->constants[constant_id - 1]; +} + // Insert a constant into a constant pool that is a slice of a source string. // Returns the id of the constant, or 0 if any potential calls to resize fail. pm_constant_id_t pm_constant_pool_insert_shared(pm_constant_pool_t *pool, const uint8_t *start, size_t length); // Insert a constant into a constant pool from memory that is now owned by the