From: Christopher Faylor Date: Sun, 7 Dec 2003 03:27:51 +0000 (+0000) Subject: * exceptions.cc (_threadinfo::remove): Avoid a linked list walk. X-Git-Tag: csl-arm-2003-q4~38 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=ae2543ed76f3271061bffc0549961aa74baba64f;p=newlib-cygwin.git * exceptions.cc (_threadinfo::remove): Avoid a linked list walk. --- diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 832b39f1e..4da0b4167 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2003-12-06 Christopher Faylor + + * exceptions.cc (_threadinfo::remove): Avoid a linked list walk. + 2003-12-06 Christopher Faylor * cygtls.h (_threadinfo::find_tls): New function. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index ea2c7e6d5..feb36327c 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -188,17 +188,15 @@ _threadinfo::init_thread (void *) void _threadinfo::remove () { - _threadinfo *t; EnterCriticalSection (&protect_linked_list); - for (t = _last_thread; t && t != this; t = t->prev) - continue; - if (t) + if (prev) { - t->prev->next = t->next; - if (t->next) - t->next->prev = t->prev; - if (t == _last_thread) - _last_thread = t->prev; + prev->next = next; + if (next) + next->prev = prev; + if (this == _last_thread) + _last_thread = prev; + prev = next = NULL; } LeaveCriticalSection (&protect_linked_list); }