Skip to content

Commit c038811

Browse files
committed
literal storage using hashmap
1 parent 4cb9e27 commit c038811

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

Diff for: jerry-core/ecma/base/ecma-literal-storage.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,9 @@ ecma_find_empty_literal_string_slot (void)
211211
* @return jmem_cpointer_t slot pointer
212212
*/
213213

214+
#if !JERRY_LIT_HASHMAP
214215
static jmem_cpointer_t *
215-
ecma_find_empty_or_same_literal_string_slot (ecma_string_t *string_p)
216+
ecma_find_empty_or_same_literal_string_slot (ecma_string_t *string_p /**< string to be searched */)
216217
{
217218
jmem_cpointer_t string_list_cp = JERRY_CONTEXT (string_list_first_cp);
218219
jmem_cpointer_t *empty_cpointer_p = NULL;
@@ -250,6 +251,7 @@ ecma_find_empty_or_same_literal_string_slot (ecma_string_t *string_p)
250251

251252
return ecma_allocate_new_string_slot ();
252253
} /* ecma_find_empty_or_same_literal_string_slot */
254+
#endif
253255

254256
/**
255257
* Find or create a literal string.

Diff for: jerry-core/lit/lit-hashmap-internal.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
#define HASHMAP_ALWAYS_INLINE __attribute__ ((always_inline)) inline
2727
#define HASHMAP_LINEAR_PROBE_LENGTH (8)
2828

29+
/**
30+
* hashmap creation options.
31+
*/
32+
2933
typedef struct hashmap_create_options_s
3034
{
31-
hashmap_uint32_t initial_capacity;
35+
hashmap_uint32_t initial_capacity; /**< initial hashmap capacity */
3236
} hashmap_create_options_t;
3337

3438
/// @brief Create a hashmap.

Diff for: jerry-core/lit/lit-hashmap.h

+14-6
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,26 @@ typedef uint8_t hashmap_uint8_t;
3030
typedef uint32_t hashmap_uint32_t;
3131
typedef uint64_t hashmap_uint64_t;
3232

33+
/**
34+
* hashmap element
35+
*/
36+
3337
typedef struct hashmap_element_s
3438
{
35-
const ecma_string_t *data;
39+
const ecma_string_t *data; /**< point to a literal */
3640
} hashmap_element_t;
3741

42+
/**
43+
* hashmap structure
44+
*/
45+
3846
typedef struct hashmap_s
3947
{
40-
hashmap_uint32_t log2_capacity;
41-
hashmap_uint32_t size;
42-
struct hashmap_element_s *data;
43-
size_t alloc_size;
44-
uint8_t initialized;
48+
hashmap_uint32_t log2_capacity; /**< hashmap capacity */
49+
hashmap_uint32_t size; /**< hashmap size*/
50+
struct hashmap_element_s *data; /**< element array */
51+
size_t alloc_size; /**< allocated size */
52+
uint8_t initialized; /**< 0 if not initialized */
4553
} hashmap_t;
4654

4755
/// @brief Initialize the hashmap.

0 commit comments

Comments
 (0)