ruby-changes:73968
From: Nobuyoshi <ko1@a...>
Date: Wed, 12 Oct 2022 22:23:23 +0900 (JST)
Subject: [ruby-changes:73968] 70bc8cc6c2 (master): Adjust indents [ci skip]
https://git.ruby-lang.org/ruby.git/commit/?id=70bc8cc6c2 From 70bc8cc6c219667dcae85bbf78bc0bc00e05c76e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 12 Oct 2022 18:27:23 +0900 Subject: Adjust indents [ci skip] --- shape.c | 126 +++++++++++++++++------------ vm_insnhelper.c | 239 +++++++++++++++++++++++++++++--------------------------- 2 files changed, 197 insertions(+), 168 deletions(-) diff --git a/shape.c b/shape.c index 0f48fa1a86..80d135b897 100644 --- a/shape.c +++ b/shape.c @@ -10,7 +10,8 @@ https://github.com/ruby/ruby/blob/trunk/shape.c#L10 * Shape getters */ static rb_shape_t* -rb_shape_get_root_shape(void) { +rb_shape_get_root_shape(void) +{ return GET_VM()->root_shape; } @@ -21,12 +22,14 @@ rb_shape_id(rb_shape_t * shape) https://github.com/ruby/ruby/blob/trunk/shape.c#L22 } static rb_shape_t* -rb_shape_get_frozen_root_shape(void) { +rb_shape_get_frozen_root_shape(void) +{ return GET_VM()->frozen_root_shape; } bool -rb_shape_root_shape_p(rb_shape_t* shape) { +rb_shape_root_shape_p(rb_shape_t* shape) +{ return shape == rb_shape_get_root_shape(); } @@ -90,7 +93,8 @@ rb_shape_get_shape(VALUE obj) https://github.com/ruby/ruby/blob/trunk/shape.c#L93 } static rb_shape_t * -rb_shape_lookup_id(rb_shape_t* shape, ID id, enum shape_type shape_type) { +rb_shape_lookup_id(rb_shape_t* shape, ID id, enum shape_type shape_type) +{ while (shape->parent_id != INVALID_SHAPE_ID) { if (shape->edge_name == id) { // If the shape type is different, we don't @@ -136,25 +140,25 @@ get_next_shape_internal(rb_shape_t* shape, ID id, VALUE obj, enum shape_type sha https://github.com/ruby/ruby/blob/trunk/shape.c#L140 new_shape->type = (uint8_t)shape_type; - switch(shape_type) { - case SHAPE_IVAR: - new_shape->iv_count = rb_shape_get_shape_by_id(new_shape->parent_id)->iv_count + 1; + switch (shape_type) { + case SHAPE_IVAR: + new_shape->iv_count = rb_shape_get_shape_by_id(new_shape->parent_id)->iv_count + 1; - // Check if we should update max_iv_count on the object's class - if (BUILTIN_TYPE(obj) == T_OBJECT) { - VALUE klass = rb_obj_class(obj); - if (new_shape->iv_count > RCLASS_EXT(klass)->max_iv_count) { - RCLASS_EXT(klass)->max_iv_count = new_shape->iv_count; - } + // Check if we should update max_iv_count on the object's class + if (BUILTIN_TYPE(obj) == T_OBJECT) { + VALUE klass = rb_obj_class(obj); + if (new_shape->iv_count > RCLASS_EXT(klass)->max_iv_count) { + RCLASS_EXT(klass)->max_iv_count = new_shape->iv_count; } - break; - case SHAPE_IVAR_UNDEF: - case SHAPE_FROZEN: - new_shape->iv_count = rb_shape_get_shape_by_id(new_shape->parent_id)->iv_count; - break; - case SHAPE_ROOT: - rb_bug("Unreachable"); - break; + } + break; + case SHAPE_IVAR_UNDEF: + case SHAPE_FROZEN: + new_shape->iv_count = rb_shape_get_shape_by_id(new_shape->parent_id)->iv_count; + break; + case SHAPE_ROOT: + rb_bug("Unreachable"); + break; } rb_id_table_insert(shape->edges, id, (VALUE)new_shape); @@ -199,13 +203,13 @@ rb_shape_transition_shape_frozen(VALUE obj) https://github.com/ruby/ruby/blob/trunk/shape.c#L203 rb_shape_t* next_shape; if (shape == rb_shape_get_root_shape()) { - switch(BUILTIN_TYPE(obj)) { - case T_OBJECT: - case T_CLASS: - case T_MODULE: - break; - default: - return; + switch (BUILTIN_TYPE(obj)) { + case T_OBJECT: + case T_CLASS: + case T_MODULE: + break; + default: + return; } next_shape = rb_shape_get_frozen_root_shape(); } @@ -239,22 +243,23 @@ rb_shape_get_next(rb_shape_t* shape, VALUE obj, ID id) https://github.com/ruby/ruby/blob/trunk/shape.c#L243 } bool -rb_shape_get_iv_index(rb_shape_t * shape, ID id, attr_index_t *value) { +rb_shape_get_iv_index(rb_shape_t * shape, ID id, attr_index_t *value) +{ while (shape->parent_id != INVALID_SHAPE_ID) { if (shape->edge_name == id) { enum shape_type shape_type; shape_type = (enum shape_type)shape->type; - switch(shape_type) { - case SHAPE_IVAR: - RUBY_ASSERT(shape->iv_count > 0); - *value = shape->iv_count - 1; - return true; - case SHAPE_IVAR_UNDEF: - case SHAPE_ROOT: - return false; - case SHAPE_FROZEN: - rb_bug("Ivar should not exist on frozen transition\n"); + switch (shape_type) { + case SHAPE_IVAR: + RUBY_ASSERT(shape->iv_count > 0); + *value = shape->iv_count - 1; + return true; + case SHAPE_IVAR_UNDEF: + case SHAPE_ROOT: + return false; + case SHAPE_FROZEN: + rb_bug("Ivar should not exist on frozen transition\n"); } } shape = rb_shape_get_shape_by_id(shape->parent_id); @@ -313,14 +318,16 @@ static const rb_data_type_t shape_data_type = { https://github.com/ruby/ruby/blob/trunk/shape.c#L318 }; static VALUE -rb_wrapped_shape_id(VALUE self) { +rb_wrapped_shape_id(VALUE self) +{ rb_shape_t * shape; TypedData_Get_Struct(self, rb_shape_t, &shape_data_type, shape); return INT2NUM(rb_shape_id(shape)); } static VALUE -rb_shape_type(VALUE self) { +rb_shape_type(VALUE self) +{ rb_shape_t * shape; TypedData_Get_Struct(self, rb_shape_t, &shape_data_type, shape); return INT2NUM(shape->type); @@ -339,16 +346,20 @@ rb_shape_parent_id(VALUE self) https://github.com/ruby/ruby/blob/trunk/shape.c#L346 } } -static VALUE parse_key(ID key) { +static VALUE +parse_key(ID key) +{ if ((key & RUBY_ID_INTERNAL) == RUBY_ID_INTERNAL) { return LONG2NUM(key); - } else { + } + else { return ID2SYM(key); } } static VALUE -rb_shape_t_to_rb_cShape(rb_shape_t *shape) { +rb_shape_t_to_rb_cShape(rb_shape_t *shape) +{ union { const rb_shape_t *in; void *out; } deconst; VALUE res; deconst.in = shape; @@ -357,7 +368,8 @@ rb_shape_t_to_rb_cShape(rb_shape_t *shape) { https://github.com/ruby/ruby/blob/trunk/shape.c#L368 return res; } -static enum rb_id_table_iterator_result rb_edges_to_hash(ID key, VALUE value, void *ref) +static enum rb_id_table_iterator_result +rb_edges_to_hash(ID key, VALUE value, void *ref) { rb_hash_aset(*(VALUE *)ref, parse_key(key), rb_shape_t_to_rb_cShape((rb_shape_t*)value)); return ID_TABLE_CONTINUE; @@ -428,15 +440,21 @@ rb_shape_parent(VALUE self) https://github.com/ruby/ruby/blob/trunk/shape.c#L440 } } -VALUE rb_shape_debug_shape(VALUE self, VALUE obj) { +VALUE +rb_shape_debug_shape(VALUE self, VALUE obj) +{ return rb_shape_t_to_rb_cShape(rb_shape_get_shape(obj)); } -VALUE rb_shape_root_shape(VALUE self) { +VALUE +rb_shape_root_shape(VALUE self) +{ return rb_shape_t_to_rb_cShape(rb_shape_get_root_shape()); } -VALUE rb_shape_frozen_root_shape(VALUE self) { +VALUE +rb_shape_frozen_root_shape(VALUE self) +{ return rb_shape_t_to_rb_cShape(rb_shape_get_frozen_root_shape()); } @@ -456,7 +474,9 @@ static VALUE edges(struct rb_id_table* edges) https://github.com/ruby/ruby/blob/trunk/shape.c#L474 return hash; } -VALUE rb_obj_shape(rb_shape_t* shape) { +VALUE +rb_obj_shape(rb_shape_t* shape) +{ VALUE rb_shape = rb_hash_new(); rb_hash_aset(rb_shape, ID2SYM(rb_intern("id")), INT2NUM(rb_shape_id(shape))); @@ -473,11 +493,15 @@ VALUE rb_obj_shape(rb_shape_t* shape) { https://github.com/ruby/ruby/blob/trunk/shape.c#L493 return rb_shape; } -static VALUE shape_transition_tree(VALUE self) { +static VALUE +shape_transition_tree(VALUE self) +{ return rb_obj_shape(rb_shape_get_root_shape()); } -static VALUE next_shape_id(VALUE self) { +static VALUE +next_shape_id(VALUE self) +{ return INT2NUM(GET_VM()->next_shape_id); } diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 9b9220a4e3..0a62b0d86c 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1130,30 +1130,31 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1130 #endif switch (BUILTIN_TYPE(obj)) { - case T_OBJECT: - ivar_list = ROBJECT_IVPTR(obj); - VM_ASSERT(rb_ractor_shareable_p(obj) ? rb_ractor_shareable_p(val) : true); + case T_OBJECT: + ivar_list = ROBJECT_IVPTR(obj); + VM_ASSERT(rb_ractor_shareable_p(obj) ? rb_ractor_shareable_p(val) : true); #if !SHAPE_IN_BASIC_FLAGS - shape_id = ROBJECT_SHAPE_ID(obj); + shape_id = ROBJECT_SHAPE_ID(obj); #endif - break; - case T_CLASS: - case T_MODULE: - { - goto general_path; - } - default: - if (FL_TEST_RAW(obj, FL_EXIVAR)) { - struct gen_ivtbl *ivtbl; - rb_gen_ivtbl_get(obj, id, &ivtbl); + break; + case T_CLASS: + case T_MODULE: + { + goto general_path; + } + default: + if (FL_TEST_RAW(obj, FL_EXIVAR)) { + (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/