From: Maxim Kokryashkin via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, imun@tarantool.org Subject: [Tarantool-patches] [PATCH luajit v3 1/4] utils: remove unnecessary insertion in AVL-tree Date: Mon, 31 Jul 2023 23:30:03 +0300 [thread overview] Message-ID: <ca68d6ed31c20b0f8a3a48633a4d84ecf6633e87.1690834846.git.m.kokryashkin@tarantool.org> (raw) In-Reply-To: <cover.1690834846.git.m.kokryashkin@tarantool.org> This patch fixes a bug in the AVL-tree implementation, which produced unnecessary inserts of values into nodes, instead of replacement. Needed for tarantool/tarantool#8700 --- .../tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua | 6 ++---- tools/utils/avl.lua | 4 ++-- tools/utils/symtab.lua | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua b/test/tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua index 30b8a3ca..c448248a 100644 --- a/test/tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua +++ b/test/tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua @@ -25,10 +25,8 @@ local function tree_contains(node, name) if node == nil then return false else - for i = 1, #node.value do - if node.value[i].name == name then - return true - end + if node.value.name == name then + return true end return tree_contains(node.left, name) or tree_contains(node.right, name) end diff --git a/tools/utils/avl.lua b/tools/utils/avl.lua index d5baa534..81ef9265 100644 --- a/tools/utils/avl.lua +++ b/tools/utils/avl.lua @@ -78,7 +78,7 @@ end function M.insert(node, key, value) assert(key, "Key can't be nil") if node == nil then - return create_node(key, { value }) + return create_node(key, value) end if key < node.key then @@ -86,7 +86,7 @@ function M.insert(node, key, value) elseif key > node.key then node.right = M.insert(node.right, key, value) else - table.insert(node.value, value) + node.value = value end update_height(node) diff --git a/tools/utils/symtab.lua b/tools/utils/symtab.lua index c26a9e8c..7f6c78f0 100644 --- a/tools/utils/symtab.lua +++ b/tools/utils/symtab.lua @@ -176,7 +176,7 @@ function M.demangle(symtab, loc) local key, value = avl.floor(symtab.cfunc, addr) if key then - return string_format("%s:%#x", value[gen].name, key) + return string_format("%s:%#x", value.name, key) end return string_format("CFUNC %#x", addr) -- 2.41.0
next prev parent reply other threads:[~2023-07-31 20:30 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-31 20:30 [Tarantool-patches] [PATCH luajit v3 0/4] sysprof: parser refactoring Maxim Kokryashkin via Tarantool-patches 2023-07-31 20:30 ` Maxim Kokryashkin via Tarantool-patches [this message] 2023-08-15 18:50 ` [Tarantool-patches] [PATCH luajit v3 1/4] utils: remove unnecessary insertion in AVL-tree Igor Munkin via Tarantool-patches 2023-07-31 20:30 ` [Tarantool-patches] [PATCH luajit v3 2/4] sysprof: remove `split by vmstate` option Maxim Kokryashkin via Tarantool-patches 2023-08-15 18:51 ` Igor Munkin via Tarantool-patches 2023-07-31 20:30 ` [Tarantool-patches] [PATCH luajit v3 3/4] tools: add execution permission to sysprof parser Maxim Kokryashkin via Tarantool-patches 2023-08-15 18:51 ` Igor Munkin via Tarantool-patches 2023-07-31 20:30 ` [Tarantool-patches] [PATCH luajit v3 4/4] sysprof: improve parser's memory footprint Maxim Kokryashkin via Tarantool-patches 2023-08-15 18:52 ` Igor Munkin via Tarantool-patches 2023-08-15 18:54 ` [Tarantool-patches] [PATCH luajit v3 0/4] sysprof: parser refactoring Igor Munkin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=ca68d6ed31c20b0f8a3a48633a4d84ecf6633e87.1690834846.git.m.kokryashkin@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imun@tarantool.org \ --cc=max.kokryashkin@gmail.com \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit v3 1/4] utils: remove unnecessary insertion in AVL-tree' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox