ext/google/cloud/debugger/debugger_c/tracer.c in google-cloud-debugger-0.36.2 vs ext/google/cloud/debugger/debugger_c/tracer.c in google-cloud-debugger-0.36.3
- old
+ new
@@ -206,29 +206,23 @@
* the thread has a thread variable "gcloud_line_trace_set" that's true.
*/
static VALUE
disable_line_trace_for_thread(VALUE thread)
{
- VALUE thread_variables_hash;
VALUE line_trace_set;
- ID locals_id;
ID line_trace_thread_id;
- VALUE line_trace_thread_flag;
- CONST_ID(locals_id, "locals");
CONST_ID(line_trace_thread_id, "gcloud_line_trace_set");
- line_trace_thread_flag = ID2SYM(line_trace_thread_id);
if (!RTEST(thread)) {
thread = rb_thread_current();
}
- thread_variables_hash = rb_ivar_get(thread, locals_id);
- line_trace_set = rb_hash_aref(thread_variables_hash, line_trace_thread_flag);
+ line_trace_set = rb_ivar_get(thread, line_trace_thread_id);
if (RTEST(line_trace_set)) {
rb_thread_remove_event_hook(thread, line_trace_callback);
- rb_hash_aset(thread_variables_hash, line_trace_thread_flag, Qfalse);
+ rb_ivar_set(thread, line_trace_thread_id, Qfalse);
}
return Qnil;
}
@@ -239,27 +233,21 @@
*/
static VALUE
enable_line_trace_for_thread(VALUE self)
{
VALUE current_thread;
- VALUE thread_variables_hash;
VALUE line_trace_set;
- ID locals_id;
ID line_trace_thread_id;
- VALUE line_trace_thread_flag;
- CONST_ID(locals_id, "locals");
CONST_ID(line_trace_thread_id, "gcloud_line_trace_set");
- line_trace_thread_flag = ID2SYM(line_trace_thread_id);
current_thread = rb_thread_current();
- thread_variables_hash = rb_ivar_get(current_thread, locals_id);
- line_trace_set = rb_hash_aref(thread_variables_hash, line_trace_thread_flag);
+ line_trace_set = rb_ivar_get(current_thread, line_trace_thread_id);
if (!RTEST(line_trace_set)) {
rb_thread_add_event_hook(current_thread, line_trace_callback, RUBY_EVENT_LINE, self);
- rb_hash_aset(thread_variables_hash, line_trace_thread_flag, Qtrue);
+ rb_ivar_set(current_thread, line_trace_thread_id, Qtrue);
}
return Qnil;
}
@@ -329,29 +317,23 @@
* the thread has a thread variable "gcloud_return_trace_set" that's true.
*/
static VALUE
disable_return_trace_for_thread(VALUE thread)
{
- VALUE thread_variables_hash;
VALUE return_trace_set;
- ID locals_id;
ID return_trace_thread_id;
- VALUE return_trace_thread_flag;
- CONST_ID(locals_id, "locals");
CONST_ID(return_trace_thread_id, "gcloud_return_trace_set");
- return_trace_thread_flag = ID2SYM(return_trace_thread_id);
if (!RTEST(thread)) {
thread = rb_thread_current();
}
- thread_variables_hash = rb_ivar_get(thread, locals_id);
- return_trace_set = rb_hash_aref(thread_variables_hash, return_trace_thread_flag);
+ return_trace_set = rb_ivar_get(thread, return_trace_thread_id);
if (RTEST(return_trace_set)) {
rb_thread_remove_event_hook(thread, (rb_event_hook_func_t)return_trace_callback);
- rb_hash_aset(thread_variables_hash, return_trace_thread_flag, Qfalse);
+ rb_ivar_set(thread, return_trace_thread_id, Qfalse);
}
return Qnil;
}
@@ -362,27 +344,20 @@
*/
static VALUE
enable_return_trace_for_thread(VALUE self)
{
VALUE current_thread;
- VALUE thread_variables_hash;
VALUE return_trace_set;
-
- ID locals_id;
ID return_trace_thread_id;
- VALUE return_trace_thread_flag;
- CONST_ID(locals_id, "locals");
CONST_ID(return_trace_thread_id, "gcloud_return_trace_set");
- return_trace_thread_flag = ID2SYM(return_trace_thread_id);
current_thread = rb_thread_current();
- thread_variables_hash = rb_ivar_get(current_thread, locals_id);
- return_trace_set = rb_hash_aref(thread_variables_hash, return_trace_thread_flag);
+ return_trace_set = rb_ivar_get(current_thread, return_trace_thread_id);
if (!RTEST(return_trace_set)) {
rb_thread_add_event_hook2(current_thread, (rb_event_hook_func_t)return_trace_callback, RETURN_TRACEPOINT_EVENTS, self, RUBY_EVENT_HOOK_FLAG_RAW_ARG | RUBY_EVENT_HOOK_FLAG_SAFE);
- rb_hash_aset(thread_variables_hash, return_trace_thread_flag, Qtrue);
+ rb_ivar_set(current_thread, return_trace_thread_id, Qtrue);
}
return Qnil;
}