]> gcc.gnu.org Git - gcc.git/commit
fortran: Remove redundant tree walk to delete element
authorMikael Morin <mikael@gcc.gnu.org>
Sat, 9 Sep 2023 09:45:11 +0000 (11:45 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Sat, 9 Sep 2023 10:39:11 +0000 (12:39 +0200)
commit1ea7130315a14ba4f66c2de76d034b33181812c5
tree0f6321a66ae42f4bc4f3b83e56baa3403183685b
parentce5e2db1f4b1949271a22c8e5245d93237ac50e0
fortran: Remove redundant tree walk to delete element

Remove preliminary walk of the symbol tree when we are about to remove an
element.  This preliminary walk was necessary because the deletion function
updated the tree without reporting back to the caller the element it had
removed.  But knowing that element is necessary to free its memory, so one
had to first get that element before it was removed from the tree.

This change updates the main deletion function delete_treap and its public
wrapper gfc_delete_bbt so that the removed element can be known by the
caller.  This makes the preliminary walk in gfc_delete_symtree redundant,
permitting its removal.

gcc/fortran/ChangeLog:

* bbt.cc (delete_treap): Add argument REMOVED, set it to the removed
element from the tree.  Change NULL to nullptr.
(gfc_delete_bbt): Return the removed element from the tree.
* gfortran.h (gfc_delete_symtree): Remove prototype.
(gfc_delete_bbt): Set return type to pointer.
* symbol.cc (gfc_delete_symtree): Make static.  Get the element to be
freed from the result of gfc_delete_bbt.  Remove the preliminary walk to
get it.
gcc/fortran/bbt.cc
gcc/fortran/gfortran.h
gcc/fortran/symbol.cc
This page took 0.065603 seconds and 5 git commands to generate.