-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to insert list in ets:insert, ets:lookup refactor #1405
Add option to insert list in ets:insert, ets:lookup refactor #1405
Conversation
76774f0
to
6ac7831
Compare
f54ef62
to
45eccdc
Compare
45eccdc
to
e5908a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still few minor changes are required, thanks for this work so far.
387dc1c
to
54951ff
Compare
I'm sorry about this additional round of comments, hope they can be somehow interesting to you and not just boring nitpicking. |
Don't worry, thank you for your patience when reviewing it ❤️ |
6e249eb
to
0f71f40
Compare
I resolved open points I believe are still open. After that we are good I think. I would appreciate also a check from @jakub-gonet |
@bettio done. Found mostly nits and one missing |
74dd710
to
4d84859
Compare
4d84859
to
8103fe7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one last thing I suggest to change, after that just git rebase main
and let's merge it (after a CI run).
src/libAtomVM/ets_hashtable.c
Outdated
struct HNode *new_node = malloc(sizeof(struct HNode)); | ||
if (IS_NULL_PTR(new_node)) { | ||
memory_destroy_heap(&heap, global); | ||
return NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we don't move this block to the beginning of this function?
e.g.
struct HNode *ets_hashtable_new_node(term entry, int keypos, GlobalContext *global)
{
struct HNode *new_node = malloc(sizeof(struct HNode));
if (IS_NULL_PTR(new_node)) {
return NULL;
}
size_t size = (size_t) memory_estimate_usage(entry);
if (memory_init_heap(&new_node->heap, size) != MEMORY_GC_OK) {
free(new_node);
return NULL;
}
term new_entry = memory_copy_term_tree(&heap, entry);
[...]
so we can avoid doing new_node->heap = heap
that doesn't smell really good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, we are also able to reduce the number of function arguments in this way.
Signed-off-by: Tomasz Sobkiewicz <tomasz.sobkiewicz@swmansion.com>
ac07f46
to
3e0cc65
Compare
Signed-off-by: Tomasz Sobkiewicz <tomasz.sobkiewicz@swmansion.com>
3e0cc65
to
7640eaa
Compare
…date_counter Add ets:update_counter Currently this solution doesn't support list of UpdateOp to update multiple counters. Based on: #1405 https://www.erlang.org/docs/23/man/ets#update_counter-3 These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
Changes:
Use Cases for the Helper Functions:
The new helper functions can be utilized in the following ETS operations to reduce code duplication:
Every mentioned function will be implemented after merging of this PR.
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later