Skip to content

Commit 294b52f

Browse files
committed
Follow the code style about else
1 parent 90e5ce6 commit 294b52f

File tree

7 files changed

+110
-57
lines changed

7 files changed

+110
-57
lines changed

builtin.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ load_with_builtin_functions(const char *feature_name, const struct rb_builtin_fu
5555
// exec
5656
if (rb_namespace_available() && rb_mNamespaceRefiner) {
5757
rb_iseq_eval_with_refinement(rb_iseq_check(iseq), rb_mNamespaceRefiner);
58-
} else {
58+
}
59+
else {
5960
rb_iseq_eval(rb_iseq_check(iseq));
6061
}
6162

class.c

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ class_duplicate_iclass_classext(VALUE iclass, rb_classext_t *mod_ext, const rb_n
274274
// See also: rb_include_class_new()
275275
if (RCLASSEXT_ICLASS_IS_ORIGIN(src) && !RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL(src)) {
276276
RCLASSEXT_M_TBL(ext) = duplicate_classext_m_tbl(RCLASSEXT_M_TBL(src), iclass, true);
277-
} else {
277+
}
278+
else {
278279
RCLASSEXT_M_TBL(ext) = RCLASSEXT_M_TBL(mod_ext);
279280
}
280281
RCLASSEXT_FIELDS(ext) = (VALUE *)st_init_numtable();
@@ -318,14 +319,16 @@ rb_class_duplicate_classext(rb_classext_t *orig, VALUE klass, const rb_namespace
318319
if (RCLASSEXT_FIELDS(orig)) {
319320
RCLASSEXT_FIELDS(ext) = (VALUE *)st_copy((st_table *)RCLASSEXT_FIELDS(orig));
320321
rb_autoload_copy_table_for_namespace((st_table *)RCLASSEXT_FIELDS(ext), ns);
321-
} else {
322+
}
323+
else {
322324
RCLASSEXT_FIELDS(ext) = (VALUE *)st_init_numtable();
323325
}
324326

325327
if (RCLASSEXT_SHARED_CONST_TBL(orig)) {
326328
RCLASSEXT_CONST_TBL(ext) = RCLASSEXT_CONST_TBL(orig);
327329
RCLASSEXT_SHARED_CONST_TBL(ext) = true;
328-
} else {
330+
}
331+
else {
329332
RCLASSEXT_CONST_TBL(ext) = duplicate_classext_const_tbl(RCLASSEXT_CONST_TBL(orig), klass);
330333
RCLASSEXT_SHARED_CONST_TBL(ext) = false;
331334
}
@@ -544,16 +547,19 @@ debug_dump_super_chain(rb_classext_t *ext, const rb_namespace_t *ns)
544547
rb_str_cat_cstr(result, " -> ");
545548
if (ns) {
546549
s = RCLASSEXT_SUPER(RCLASS_EXT_READABLE_IN_NS(s, ns));
547-
} else {
550+
}
551+
else {
548552
s = RCLASSEXT_SUPER(RCLASS_EXT_PRIME(s));
549553
}
550-
} else {
554+
}
555+
else {
551556
chaining = false;
552557
}
553558
}
554559
if (count >= 100) {
555560
rb_str_cat_cstr(result, " -> ... (chain size >= 100)\n");
556-
} else {
561+
}
562+
else {
557563
rb_str_cat_cstr(result, "\n");
558564
}
559565
return result;
@@ -571,9 +577,11 @@ debug_dump_ivars_foreach_i(st_data_t k, st_data_t v, st_data_t arg)
571577
// to suppress the very long Gem ivar values
572578
if (key == rb_intern("@loaded_specs")) {
573579
rb_str_cat_cstr(result, "[ ... ]");
574-
} else if (key == rb_intern("@path_to_default_spec_map")) {
580+
}
581+
else if (key == rb_intern("@path_to_default_spec_map")) {
575582
rb_str_cat_cstr(result, "{ ... }");
576-
} else {
583+
}
584+
else {
577585
rb_str_concat(result, debug_dump_inspect_or_return_type(value));
578586
}
579587
rb_str_cat_cstr(result, "\n");
@@ -607,7 +615,8 @@ debug_dump_sorted_methods_i(ID key, VALUE value, void *data)
607615
// snprintf(buf, 2048, "%s[%p](*)", rb_id2name(key), me);
608616
snprintf(buf, 2048, "%s(*)", rb_id2name(key));
609617
rb_ary_push(ary, rb_str_new_cstr(buf));
610-
} else {
618+
}
619+
else {
611620
// snprintf(buf, 2048, "%s[%p]", rb_id2name(key), me);
612621
snprintf(buf, 2048, "%s", rb_id2name(key));
613622
rb_ary_push(ary, rb_str_new_cstr(buf));
@@ -666,58 +675,66 @@ debug_dump_classext(rb_classext_t *ext, VALUE klass, const rb_namespace_t *ns)
666675
} else {
667676
if (!RCLASSEXT_FIELDS(ext)) {
668677
rb_str_cat_cstr(result, "Ivars: NONE\n");
669-
} else if (st_table_size((st_table *)RCLASSEXT_FIELDS(ext)) == 0) {
678+
}
679+
else if (st_table_size((st_table *)RCLASSEXT_FIELDS(ext)) == 0) {
670680
snprintf(buf, 2048, "IVars: NONE (%p)\n", (void *)RCLASSEXT_FIELDS(ext));
671681
rb_str_cat_cstr(result, buf);
672-
} else {
682+
}
683+
else {
673684
snprintf(buf, 2048, "IVars: %zu (%p)\n", st_table_size((st_table *)RCLASSEXT_FIELDS(ext)), (void *)RCLASSEXT_FIELDS(ext));
674685
rb_str_cat_cstr(result, buf);
675686
st_foreach((st_table *)RCLASSEXT_FIELDS(ext), debug_dump_ivars_foreach_i, (st_data_t)result);
676687
}
677688
}
678689
if (!RCLASSEXT_CONST_TBL(ext) || rb_id_table_size(RCLASSEXT_CONST_TBL(ext)) == 0) {
679690
rb_str_cat_cstr(result, "Constants: NONE\n");
680-
} else {
691+
}
692+
else {
681693
snprintf(buf, 2048, "Constants: %zu\n ", rb_id_table_size(RCLASSEXT_CONST_TBL(ext)));
682694
rb_str_cat_cstr(result, buf);
683695
rb_str_concat(result, debug_dump_sorted_constants(RCLASSEXT_CONST_TBL(ext)));
684696
rb_str_cat_cstr(result, ".\n");
685697
}
686698
if (!RCLASSEXT_M_TBL(ext) || rb_id_table_size(RCLASSEXT_M_TBL(ext)) == 0) {
687699
rb_str_cat_cstr(result, "Methods: NONE\n");
688-
} else {
700+
}
701+
else {
689702
snprintf(buf, 2048, "Methods: %zu\n ", rb_id_table_size(RCLASSEXT_M_TBL(ext)));
690703
rb_str_cat_cstr(result, buf);
691704
rb_str_concat(result, debug_dump_sorted_methods(RCLASSEXT_M_TBL(ext)));
692705
rb_str_cat_cstr(result, ".\n");
693706
}
694707
if (!RCLASSEXT_CALLABLE_M_TBL(ext) || rb_id_table_size(RCLASSEXT_CALLABLE_M_TBL(ext)) == 0) {
695708
rb_str_cat_cstr(result, "Callable Methods: NONE\n");
696-
} else {
709+
}
710+
else {
697711
snprintf(buf, 2048, "Callable Methods: %zu\n ", rb_id_table_size(RCLASSEXT_CALLABLE_M_TBL(ext)));
698712
rb_str_cat_cstr(result, buf);
699713
rb_str_concat(result, debug_dump_sorted_list_of_id_table_keys(RCLASSEXT_CALLABLE_M_TBL(ext)));
700714
rb_str_cat_cstr(result, ".\n");
701715
}
702716
if (!RCLASSEXT_CC_TBL(ext) || rb_id_table_size(RCLASSEXT_CC_TBL(ext)) == 0) {
703717
rb_str_cat_cstr(result, "Call Caches: NONE\n");
704-
} else {
718+
}
719+
else {
705720
snprintf(buf, 2048, "Call Caches: %zu\n ", rb_id_table_size(RCLASSEXT_CC_TBL(ext)));
706721
rb_str_cat_cstr(result, buf);
707722
rb_str_concat(result, debug_dump_sorted_list_of_id_table_keys(RCLASSEXT_CC_TBL(ext)));
708723
rb_str_cat_cstr(result, ".\n");
709724
}
710725
if (!RCLASSEXT_CVC_TBL(ext) || rb_id_table_size(RCLASSEXT_CVC_TBL(ext)) == 0) {
711726
rb_str_cat_cstr(result, "CVar Caches: NONE\n");
712-
} else {
727+
}
728+
else {
713729
snprintf(buf, 2048, "CVar Caches: %zu\n ", rb_id_table_size(RCLASSEXT_CVC_TBL(ext)));
714730
rb_str_cat_cstr(result, buf);
715731
rb_str_concat(result, debug_dump_sorted_list_of_id_table_keys(RCLASSEXT_CVC_TBL(ext)));
716732
rb_str_cat_cstr(result, ".\n");
717733
}
718734
if (RCLASSEXT_SUPERCLASS_DEPTH(ext) == 0) {
719735
rb_str_cat_cstr(result, "Superclasses: NONE\n");
720-
} else {
736+
}
737+
else {
721738
rb_str_cat_cstr(result, "Superclasses: ");
722739
len = (int)RCLASSEXT_SUPERCLASS_DEPTH(ext);
723740
for (i=0; i<len; i++) {
@@ -732,7 +749,8 @@ debug_dump_classext(rb_classext_t *ext, VALUE klass, const rb_namespace_t *ns)
732749
rb_str_cat_cstr(result, buf);
733750
if (!RCLASSEXT_SUBCLASSES(ext)) {
734751
rb_str_cat_cstr(result, "Subclasses: NONE\n");
735-
} else {
752+
}
753+
else {
736754
rb_str_cat_cstr(result, "Subclasses: ");
737755
subclass = RCLASSEXT_SUBCLASSES(ext)->head;
738756
while (subclass->next) {
@@ -746,26 +764,30 @@ debug_dump_classext(rb_classext_t *ext, VALUE klass, const rb_namespace_t *ns)
746764
}
747765
if (!RCLASSEXT_NS_SUPER_SUBCLASSES(ext)) {
748766
rb_str_cat_cstr(result, "Namespace Super Subclass Table: NONE\n");
749-
} else {
767+
}
768+
else {
750769
snprintf(buf, 2048, "Namespace Super Subclass Table: %p\n", (void *)RCLASSEXT_NS_SUPER_SUBCLASSES(ext));
751770
rb_str_cat_cstr(result, buf);
752771
}
753772
if (!RCLASSEXT_NS_MODULE_SUBCLASSES(ext)) {
754773
rb_str_cat_cstr(result, "Namespace Module Subclass Table: NONE\n");
755-
} else {
774+
}
775+
else {
756776
snprintf(buf, 2048, "Namespace Module Subclass Table: %p\n", (void *)RCLASSEXT_NS_MODULE_SUBCLASSES(ext));
757777
rb_str_cat_cstr(result, buf);
758778
}
759779
if (!RCLASSEXT_ORIGIN(ext)) {
760780
rb_str_cat_cstr(result, "Origin: NONE\n");
761-
} else {
781+
}
782+
else {
762783
rb_str_cat_cstr(result, "Origin: ");
763784
rb_str_concat(result, debug_dump_inspect_or_return_type(RCLASSEXT_ORIGIN(ext)));
764785
rb_str_cat_cstr(result, "\n");
765786
}
766787
if (!RCLASSEXT_INCLUDER(ext)) {
767788
rb_str_cat_cstr(result, "Includer: NONE\n");
768-
} else {
789+
}
790+
else {
769791
rb_str_cat_cstr(result, "Includer: ");
770792
rb_str_concat(result, debug_dump_inspect_or_return_type(RCLASSEXT_INCLUDER(ext)));
771793
rb_str_cat_cstr(result, "\n");
@@ -818,13 +840,15 @@ rb_class_debug_dump_all_classext(VALUE klass)
818840
rb_str_cat_cstr(r, "klass: ");
819841
if (METACLASS_OF(klass)) {
820842
rb_str_concat(r, debug_dump_inspect_or_return_type(METACLASS_OF(klass)));
821-
} else {
843+
}
844+
else {
822845
rb_str_cat_cstr(r, "NONE\n");
823846
}
824847
rb_str_cat_cstr(r, "\n");
825848
if (RCLASS_SINGLETON_P(klass)) {
826849
rb_str_cat_cstr(r, "singleton class: true\n");
827-
} else {
850+
}
851+
else {
828852
rb_str_cat_cstr(r, "singleton class: false\n");
829853
}
830854
snprintf(buf, 2048,
@@ -866,7 +890,8 @@ rb_class_debug_print_classext(const char *label, const char *opt, VALUE klass)
866890
VALUE d = rb_class_debug_dump_all_classext(klass);
867891
if (opt) {
868892
fprintf(stderr, "***** %s (%s)\n%s", label, opt, StringValueCStr(d));
869-
} else {
893+
}
894+
else {
870895
fprintf(stderr, "***** %s\n%s", label, StringValueCStr(d));
871896
}
872897
}
@@ -930,7 +955,8 @@ push_subclass_entry_to_list(VALUE super, VALUE klass, bool is_module)
930955

931956
if (is_module) {
932957
RCLASS_WRITE_NS_MODULE_SUBCLASSES(klass, anchor->ns_subclasses);
933-
} else {
958+
}
959+
else {
934960
RCLASS_WRITE_NS_SUPER_SUBCLASSES(klass, anchor->ns_subclasses);
935961
}
936962
}
@@ -989,13 +1015,15 @@ remove_class_from_subclasses(struct st_table *tbl, VALUE ns_id, VALUE klass)
9891015
if (first_entry) {
9901016
if (next) {
9911017
st_insert(tbl, ns_id, (st_data_t)next);
992-
} else {
1018+
}
1019+
else {
9931020
// no subclass entries in this ns
9941021
st_delete(tbl, &ns_id, NULL);
9951022
}
9961023
}
9971024
break;
998-
} else if (first_entry) {
1025+
}
1026+
else if (first_entry) {
9991027
first_entry = false;
10001028
}
10011029
entry = entry->next;
@@ -1174,7 +1202,8 @@ class_associate_super(VALUE klass, VALUE super, bool init)
11741202
}
11751203
if (init) {
11761204
RCLASS_SET_SUPER(klass, super);
1177-
} else {
1205+
}
1206+
else {
11781207
RCLASS_WRITE_SUPER(klass, super);
11791208
}
11801209
rb_class_update_superclasses(klass);
@@ -1274,7 +1303,8 @@ rb_class_update_superclasses(VALUE klass)
12741303
super_depth = RCLASS_SUPERCLASS_DEPTH(super);
12751304
if (RCLASS_SUPERCLASSES_WITH_SELF_P(super)) {
12761305
superclasses = RCLASS_SUPERCLASSES(super);
1277-
} else {
1306+
}
1307+
else {
12781308
superclasses = class_superclasses_including_self(super);
12791309
RCLASS_WRITE_SUPERCLASSES(super, super_depth, superclasses, true, true);
12801310
}
@@ -2117,7 +2147,8 @@ rb_include_class_new(VALUE module, VALUE super)
21172147
RUBY_ASSERT(!RB_TYPE_P(module, T_ICLASS));
21182148
if (RCLASS_WRITABLE_CONST_TBL(module)) {
21192149
RCLASS_SET_CONST_TBL(klass, RCLASS_WRITABLE_CONST_TBL(module), true);
2120-
} else {
2150+
}
2151+
else {
21212152
RCLASS_WRITE_CONST_TBL(module, rb_id_table_create(0), false);
21222153
RCLASS_SET_CONST_TBL(klass, RCLASS_WRITABLE_CONST_TBL(module), true);
21232154
}

gc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,7 +2243,8 @@ rb_obj_memsize_of(VALUE obj)
22432243

22442244
if (rb_shape_obj_too_complex_p(obj)) {
22452245
rb_class_classext_foreach(obj, classext_fields_hash_memsize, (void *)&size);
2246-
} else {
2246+
}
2247+
else {
22472248
// class IV sizes are allocated as powers of two
22482249
size += SIZEOF_VALUE << bit_length(RCLASS_FIELDS_COUNT(obj));
22492250
}
@@ -3746,7 +3747,8 @@ update_classext(rb_classext_t *ext, bool is_prime, VALUE namespace, void *arg)
37463747

37473748
if (args->obj_too_complex) {
37483749
gc_ref_update_table_values_only((st_table *)RCLASSEXT_FIELDS(ext));
3749-
} else {
3750+
}
3751+
else {
37503752
// Classext is not copied in this case
37513753
for (attr_index_t i = 0; i < RCLASS_FIELDS_COUNT(klass); i++) {
37523754
UPDATE_IF_MOVED(objspace, RCLASSEXT_FIELDS(RCLASS_EXT_PRIME(klass))[i]);

load.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,8 @@ iseq_eval_in_namespace(VALUE arg)
798798
struct iseq_eval_in_namespace_data *data = (struct iseq_eval_in_namespace_data *)arg;
799799
if (rb_namespace_available() && data->in_builtin) {
800800
return rb_iseq_eval_with_refinement(data->iseq, rb_mNamespaceRefiner);
801-
} else {
801+
}
802+
else {
802803
return rb_iseq_eval(data->iseq);
803804
}
804805
}
@@ -865,7 +866,8 @@ load_iseq_eval(rb_execution_context_t *ec, VALUE fname)
865866
.in_builtin = NAMESPACE_BUILTIN_P(loading_ns),
866867
};
867868
rb_namespace_exec(loading_ns, iseq_eval_in_namespace, (VALUE)&arg);
868-
} else {
869+
}
870+
else {
869871
rb_iseq_eval(iseq);
870872
}
871873
}
@@ -891,7 +893,8 @@ load_wrapping(rb_execution_context_t *ec, VALUE fname, VALUE load_wrapper)
891893
ns->top_self = rb_obj_clone(rb_vm_top_self());
892894
}
893895
th->top_self = ns->top_self;
894-
} else {
896+
}
897+
else {
895898
th->top_self = rb_obj_clone(rb_vm_top_self());
896899
}
897900
th->top_wrapper = load_wrapper;
@@ -1441,7 +1444,8 @@ require_internal(rb_execution_context_t *ec, VALUE fname, int exception, bool wa
14411444
// check with NAMESPACE_OPTIONAL_P (not NAMESPACE_USER_P) for NS1::xxx naming
14421445
// it is not expected for the main namespace
14431446
load_wrapping(saved.ec, path, vm_ns->ns->ns_object);
1444-
} else {
1447+
}
1448+
else {
14451449
load_iseq_eval(saved.ec, path);
14461450
}
14471451
break;

mini_builtin.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
111111
const rb_iseq_t *iseq;
112112
if (rb_namespace_available() && rb_mNamespaceRefiner) {
113113
load_with_builtin_functions(feature_name, table);
114-
} else {
114+
}
115+
else {
115116
iseq = builtin_iseq_load(feature_name, table);
116117
rb_iseq_eval(iseq);
117118
}

0 commit comments

Comments
 (0)