This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfa] libiberty: splay tree performance improvement


On Mon, Jun 28, 2004 at 04:07:55PM -0400, Frank Ch. Eigler wrote:
> +  /* If we just splayed the tree with the same key, do nothing.  */
> +  if (sp->last_splayed_key_p &&
> +      (*sp->comp)(sp->last_splayed_key, key) == 0)
> +    return;
> +
>    splay_tree_splay_helper (sp, key, &sp->root, 
>  			   /*grandparent=*/0, /*parent=*/0); 
> +
> +  /* Cache this splay key. */
> +  sp->last_splayed_key = key;
> +  sp->last_splayed_key_p = 1;

How can you cache this value across calls without knowing the form
of the key?  It could be a pointer located in stack memory that isn't
valid after the caller returns.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]