Minor simplification of (Python) find_thread_object
Commit Message
Since the reference to the Inferior Python object is managed by
gdbpy_ref (RAII), we can return directly from the loop. It's just a
leftover from the cleanups era.
gdb/ChangeLog:
* python/py-inferior.c (find_thread_object): Return directly
from the loop. Remove "found" variable.
---
gdb/python/py-inferior.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
Comments
On 2017-01-21 23:50, Simon Marchi wrote:
> Since the reference to the Inferior Python object is managed by
> gdbpy_ref (RAII), we can return directly from the loop. It's just a
> leftover from the cleanups era.
>
> gdb/ChangeLog:
>
> * python/py-inferior.c (find_thread_object): Return directly
> from the loop. Remove "found" variable.
> ---
> gdb/python/py-inferior.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
> index 9e10d62c51..f3ae82ed54 100644
> --- a/gdb/python/py-inferior.c
> +++ b/gdb/python/py-inferior.c
> @@ -264,13 +264,7 @@ find_thread_object (ptid_t ptid)
> for (thread = ((inferior_object *)(inf_obj.get ()))->threads;
> thread;
> thread = thread->next)
> if (ptid_equal (thread->thread_obj->thread->ptid, ptid))
> - {
> - found = thread->thread_obj;
> - break;
> - }
> -
> - if (found)
> - return found;
> + return thread->thread_obj;
>
> return NULL;
> }
Self-review: I have just noticed that the "found" variable declaration
can be removed.
On 01/23/2017 04:26 PM, Simon Marchi wrote:
> Self-review: I have just noticed that the "found" variable declaration
> can be removed.
OK with that change.
Thanks,
Pedro Alves
On 2017-01-23 12:32, Pedro Alves wrote:
> On 01/23/2017 04:26 PM, Simon Marchi wrote:
>
>> Self-review: I have just noticed that the "found" variable declaration
>> can be removed.
>
> OK with that change.
>
> Thanks,
> Pedro Alves
Thanks, pushed.
@@ -264,13 +264,7 @@ find_thread_object (ptid_t ptid)
for (thread = ((inferior_object *)(inf_obj.get ()))->threads; thread;
thread = thread->next)
if (ptid_equal (thread->thread_obj->thread->ptid, ptid))
- {
- found = thread->thread_obj;
- break;
- }
-
- if (found)
- return found;
+ return thread->thread_obj;
return NULL;
}