Skip to content

Commit 18dac12

Browse files
committed
Improve syntax style consistency in shape.c and shape.h
Most of this code use the `type * name` style, while the overwhemling majority of the rest of ruby use the `type *name` style. This is a cosmetic change, but helps with readability.
1 parent 5e8b744 commit 18dac12

File tree

3 files changed

+67
-67
lines changed

3 files changed

+67
-67
lines changed

object.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
329329
RUBY_ASSERT(!RB_TYPE_P(obj, T_CLASS) && !RB_TYPE_P(obj, T_MODULE));
330330

331331
RUBY_ASSERT(BUILTIN_TYPE(dest) == BUILTIN_TYPE(obj));
332-
rb_shape_t * src_shape = rb_shape_get_shape(obj);
332+
rb_shape_t *src_shape = rb_shape_get_shape(obj);
333333

334334
if (rb_shape_obj_too_complex(obj)) {
335335
// obj is TOO_COMPLEX so we can copy its iv_hash
@@ -340,7 +340,7 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
340340
}
341341

342342
uint32_t src_num_ivs = RBASIC_IV_COUNT(obj);
343-
rb_shape_t * shape_to_set_on_dest = src_shape;
343+
rb_shape_t *shape_to_set_on_dest = src_shape;
344344
VALUE * src_buf;
345345
VALUE * dest_buf;
346346

@@ -356,7 +356,7 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj)
356356
src_buf = ROBJECT_IVPTR(obj);
357357
dest_buf = ROBJECT_IVPTR(dest);
358358

359-
rb_shape_t * initial_shape = rb_shape_get_shape(dest);
359+
rb_shape_t *initial_shape = rb_shape_get_shape(dest);
360360

361361
if (initial_shape->heap_index != src_shape->heap_index) {
362362
RUBY_ASSERT(initial_shape->type == SHAPE_T_OBJECT);
@@ -506,7 +506,7 @@ rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze)
506506
}
507507

508508
if (RB_OBJ_FROZEN(obj)) {
509-
rb_shape_t * next_shape = rb_shape_transition_shape_frozen(clone);
509+
rb_shape_t *next_shape = rb_shape_transition_shape_frozen(clone);
510510
if (!rb_shape_obj_too_complex(clone) && next_shape->type == SHAPE_OBJ_TOO_COMPLEX) {
511511
rb_evict_ivars_to_hash(clone);
512512
}
@@ -528,7 +528,7 @@ rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze)
528528
argv[1] = freeze_true_hash;
529529
rb_funcallv_kw(clone, id_init_clone, 2, argv, RB_PASS_KEYWORDS);
530530
RBASIC(clone)->flags |= FL_FREEZE;
531-
rb_shape_t * next_shape = rb_shape_transition_shape_frozen(clone);
531+
rb_shape_t *next_shape = rb_shape_transition_shape_frozen(clone);
532532
// If we're out of shapes, but we want to freeze, then we need to
533533
// evacuate this clone to a hash
534534
if (!rb_shape_obj_too_complex(clone) && next_shape->type == SHAPE_OBJ_TOO_COMPLEX) {

shape.c

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -51,33 +51,33 @@ static ID id_t_object;
5151
#define RED 0x1
5252

5353
static redblack_node_t *
54-
redblack_left(redblack_node_t * node)
54+
redblack_left(redblack_node_t *node)
5555
{
5656
if (node->l == LEAF) {
5757
return LEAF;
5858
}
5959
else {
6060
RUBY_ASSERT(node->l < GET_SHAPE_TREE()->cache_size);
61-
redblack_node_t * left = &GET_SHAPE_TREE()->shape_cache[node->l - 1];
61+
redblack_node_t *left = &GET_SHAPE_TREE()->shape_cache[node->l - 1];
6262
return left;
6363
}
6464
}
6565

6666
static redblack_node_t *
67-
redblack_right(redblack_node_t * node)
67+
redblack_right(redblack_node_t *node)
6868
{
6969
if (node->r == LEAF) {
7070
return LEAF;
7171
}
7272
else {
7373
RUBY_ASSERT(node->r < GET_SHAPE_TREE()->cache_size);
74-
redblack_node_t * right = &GET_SHAPE_TREE()->shape_cache[node->r - 1];
74+
redblack_node_t *right = &GET_SHAPE_TREE()->shape_cache[node->r - 1];
7575
return right;
7676
}
7777
}
7878

7979
static redblack_node_t *
80-
redblack_find(redblack_node_t * tree, ID key)
80+
redblack_find(redblack_node_t *tree, ID key)
8181
{
8282
if (tree == LEAF) {
8383
return LEAF;
@@ -101,7 +101,7 @@ redblack_find(redblack_node_t * tree, ID key)
101101
}
102102

103103
static inline rb_shape_t *
104-
redblack_value(redblack_node_t * node)
104+
redblack_value(redblack_node_t *node)
105105
{
106106
// Color is stored in the bottom bit of the shape pointer
107107
// Mask away the bit so we get the actual pointer back
@@ -110,33 +110,33 @@ redblack_value(redblack_node_t * node)
110110

111111
#ifdef HAVE_MMAP
112112
static inline char
113-
redblack_color(redblack_node_t * node)
113+
redblack_color(redblack_node_t *node)
114114
{
115115
return node && ((uintptr_t)node->value & RED);
116116
}
117117

118118
static inline bool
119-
redblack_red_p(redblack_node_t * node)
119+
redblack_red_p(redblack_node_t *node)
120120
{
121121
return redblack_color(node) == RED;
122122
}
123123

124124
static redblack_id_t
125-
redblack_id_for(redblack_node_t * node)
125+
redblack_id_for(redblack_node_t *node)
126126
{
127127
RUBY_ASSERT(node || node == LEAF);
128128
if (node == LEAF) {
129129
return 0;
130130
}
131131
else {
132-
redblack_node_t * redblack_nodes = GET_SHAPE_TREE()->shape_cache;
132+
redblack_node_t *redblack_nodes = GET_SHAPE_TREE()->shape_cache;
133133
redblack_id_t id = (redblack_id_t)(node - redblack_nodes);
134134
return id + 1;
135135
}
136136
}
137137

138138
static redblack_node_t *
139-
redblack_new(char color, ID key, rb_shape_t * value, redblack_node_t * left, redblack_node_t * right)
139+
redblack_new(char color, ID key, rb_shape_t *value, redblack_node_t *left, redblack_node_t *right)
140140
{
141141
if (GET_SHAPE_TREE()->cache_size + 1 >= REDBLACK_CACHE_SIZE) {
142142
// We're out of cache, just quit
@@ -146,8 +146,8 @@ redblack_new(char color, ID key, rb_shape_t * value, redblack_node_t * left, red
146146
RUBY_ASSERT(left == LEAF || left->key < key);
147147
RUBY_ASSERT(right == LEAF || right->key > key);
148148

149-
redblack_node_t * redblack_nodes = GET_SHAPE_TREE()->shape_cache;
150-
redblack_node_t * node = &redblack_nodes[(GET_SHAPE_TREE()->cache_size)++];
149+
redblack_node_t *redblack_nodes = GET_SHAPE_TREE()->shape_cache;
150+
redblack_node_t *node = &redblack_nodes[(GET_SHAPE_TREE()->cache_size)++];
151151
node->key = key;
152152
node->value = (rb_shape_t *)((uintptr_t)value | color);
153153
node->l = redblack_id_for(left);
@@ -156,7 +156,7 @@ redblack_new(char color, ID key, rb_shape_t * value, redblack_node_t * left, red
156156
}
157157

158158
static redblack_node_t *
159-
redblack_balance(char color, ID key, rb_shape_t * value, redblack_node_t * left, redblack_node_t * right)
159+
redblack_balance(char color, ID key, rb_shape_t *value, redblack_node_t *left, redblack_node_t *right)
160160
{
161161
if (color == BLACK) {
162162
ID new_key, new_left_key, new_right_key;
@@ -243,7 +243,7 @@ redblack_balance(char color, ID key, rb_shape_t * value, redblack_node_t * left,
243243
}
244244

245245
static redblack_node_t *
246-
redblack_insert_aux(redblack_node_t * tree, ID key, rb_shape_t * value)
246+
redblack_insert_aux(redblack_node_t *tree, ID key, rb_shape_t *value)
247247
{
248248
if (tree == LEAF) {
249249
return redblack_new(RED, key, value, LEAF, LEAF);
@@ -277,16 +277,16 @@ redblack_insert_aux(redblack_node_t * tree, ID key, rb_shape_t * value)
277277
}
278278

279279
static redblack_node_t *
280-
redblack_force_black(redblack_node_t * node)
280+
redblack_force_black(redblack_node_t *node)
281281
{
282282
node->value = redblack_value(node);
283283
return node;
284284
}
285285

286286
static redblack_node_t *
287-
redblack_insert(redblack_node_t * tree, ID key, rb_shape_t * value)
287+
redblack_insert(redblack_node_t *tree, ID key, rb_shape_t *value)
288288
{
289-
redblack_node_t * root = redblack_insert_aux(tree, key, value);
289+
redblack_node_t *root = redblack_insert_aux(tree, key, value);
290290

291291
if (redblack_red_p(root)) {
292292
return redblack_force_black(root);
@@ -309,7 +309,7 @@ rb_shape_get_root_shape(void)
309309
}
310310

311311
shape_id_t
312-
rb_shape_id(rb_shape_t * shape)
312+
rb_shape_id(rb_shape_t *shape)
313313
{
314314
return (shape_id_t)(shape - GET_SHAPE_TREE()->shape_list);
315315
}
@@ -335,7 +335,7 @@ rb_shape_get_shape_by_id(shape_id_t shape_id)
335335
}
336336

337337
rb_shape_t *
338-
rb_shape_get_parent(rb_shape_t * shape)
338+
rb_shape_get_parent(rb_shape_t *shape)
339339
{
340340
return rb_shape_get_shape_by_id(shape->parent_id);
341341
}
@@ -368,7 +368,7 @@ rb_shape_get_shape_id(VALUE obj)
368368
}
369369

370370
size_t
371-
rb_shape_depth(rb_shape_t * shape)
371+
rb_shape_depth(rb_shape_t *shape)
372372
{
373373
size_t depth = 1;
374374

@@ -403,7 +403,7 @@ shape_alloc(void)
403403
static rb_shape_t *
404404
rb_shape_alloc_with_parent_id(ID edge_name, shape_id_t parent_id)
405405
{
406-
rb_shape_t * shape = shape_alloc();
406+
rb_shape_t *shape = shape_alloc();
407407

408408
shape->edge_name = edge_name;
409409
shape->next_iv_index = 0;
@@ -414,9 +414,9 @@ rb_shape_alloc_with_parent_id(ID edge_name, shape_id_t parent_id)
414414
}
415415

416416
static rb_shape_t *
417-
rb_shape_alloc(ID edge_name, rb_shape_t * parent, enum shape_type type)
417+
rb_shape_alloc(ID edge_name, rb_shape_t *parent, enum shape_type type)
418418
{
419-
rb_shape_t * shape = rb_shape_alloc_with_parent_id(edge_name, rb_shape_id(parent));
419+
rb_shape_t *shape = rb_shape_alloc_with_parent_id(edge_name, rb_shape_id(parent));
420420
shape->type = (uint8_t)type;
421421
shape->heap_index = parent->heap_index;
422422
shape->capacity = parent->capacity;
@@ -426,10 +426,10 @@ rb_shape_alloc(ID edge_name, rb_shape_t * parent, enum shape_type type)
426426

427427
#ifdef HAVE_MMAP
428428
static redblack_node_t *
429-
redblack_cache_ancestors(rb_shape_t * shape)
429+
redblack_cache_ancestors(rb_shape_t *shape)
430430
{
431431
if (!(shape->ancestor_index || shape->parent_id == INVALID_SHAPE_ID)) {
432-
redblack_node_t * parent_index;
432+
redblack_node_t *parent_index;
433433

434434
parent_index = redblack_cache_ancestors(rb_shape_get_parent(shape));
435435

@@ -453,16 +453,16 @@ redblack_cache_ancestors(rb_shape_t * shape)
453453
}
454454
#else
455455
static redblack_node_t *
456-
redblack_cache_ancestors(rb_shape_t * shape)
456+
redblack_cache_ancestors(rb_shape_t *shape)
457457
{
458458
return LEAF;
459459
}
460460
#endif
461461

462462
static rb_shape_t *
463-
rb_shape_alloc_new_child(ID id, rb_shape_t * shape, enum shape_type shape_type)
463+
rb_shape_alloc_new_child(ID id, rb_shape_t *shape, enum shape_type shape_type)
464464
{
465-
rb_shape_t * new_shape = rb_shape_alloc(id, shape, shape_type);
465+
rb_shape_t *new_shape = rb_shape_alloc(id, shape, shape_type);
466466

467467
switch (shape_type) {
468468
case SHAPE_IVAR:
@@ -490,7 +490,7 @@ rb_shape_alloc_new_child(ID id, rb_shape_t * shape, enum shape_type shape_type)
490490
}
491491

492492
static rb_shape_t*
493-
get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, bool * variation_created, bool new_variations_allowed)
493+
get_next_shape_internal(rb_shape_t *shape, ID id, enum shape_type shape_type, bool *variation_created, bool new_variations_allowed)
494494
{
495495
rb_shape_t *res = NULL;
496496

@@ -505,7 +505,7 @@ get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, b
505505
if (shape->edges) {
506506
// Check if it only has one child
507507
if (SINGLE_CHILD_P(shape->edges)) {
508-
rb_shape_t * child = SINGLE_CHILD(shape->edges);
508+
rb_shape_t *child = SINGLE_CHILD(shape->edges);
509509
// If the one child has a matching edge name, then great,
510510
// we found what we want.
511511
if (child->edge_name == id) {
@@ -529,7 +529,7 @@ get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, b
529529
res = rb_shape_get_shape_by_id(OBJ_TOO_COMPLEX_SHAPE_ID);
530530
}
531531
else {
532-
rb_shape_t * new_shape = rb_shape_alloc_new_child(id, shape, shape_type);
532+
rb_shape_t *new_shape = rb_shape_alloc_new_child(id, shape, shape_type);
533533

534534
if (!shape->edges) {
535535
// If the shape had no edge yet, we can directly set the new child
@@ -538,7 +538,7 @@ get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, b
538538
else {
539539
// If the edge was single child we need to allocate a table.
540540
if (SINGLE_CHILD_P(shape->edges)) {
541-
rb_shape_t * old_child = SINGLE_CHILD(shape->edges);
541+
rb_shape_t *old_child = SINGLE_CHILD(shape->edges);
542542
shape->edges = rb_id_table_create(2);
543543
rb_id_table_insert(shape->edges, old_child->edge_name, (VALUE)old_child);
544544
}
@@ -691,7 +691,7 @@ rb_shape_transition_shape_frozen(VALUE obj)
691691
* max_iv_count
692692
*/
693693
rb_shape_t *
694-
rb_shape_get_next_iv_shape(rb_shape_t* shape, ID id)
694+
rb_shape_get_next_iv_shape(rb_shape_t *shape, ID id)
695695
{
696696
RUBY_ASSERT(!is_instance_id(id) || RTEST(rb_sym2str(ID2SYM(id))));
697697
bool dont_care;
@@ -775,7 +775,7 @@ rb_shape_get_iv_index_with_hint(shape_id_t shape_id, ID id, attr_index_t *value,
775775
return rb_shape_get_iv_index(shape, id, value);
776776
}
777777

778-
rb_shape_t * shape_hint = rb_shape_get_shape_by_id(*shape_id_hint);
778+
rb_shape_t *shape_hint = rb_shape_get_shape_by_id(*shape_id_hint);
779779

780780
// We assume it's likely shape_id_hint and shape_id have a close common
781781
// ancestor, so we check up to ANCESTOR_SEARCH_MAX_DEPTH ancestors before
@@ -925,7 +925,7 @@ rb_shape_traverse_from_new_root(rb_shape_t *initial_shape, rb_shape_t *dest_shap
925925

926926
VALUE lookup_result;
927927
if (SINGLE_CHILD_P(next_shape->edges)) {
928-
rb_shape_t * child = SINGLE_CHILD(next_shape->edges);
928+
rb_shape_t *child = SINGLE_CHILD(next_shape->edges);
929929
if (child->edge_name == dest_shape->edge_name) {
930930
return child;
931931
}
@@ -954,12 +954,12 @@ rb_shape_traverse_from_new_root(rb_shape_t *initial_shape, rb_shape_t *dest_shap
954954
}
955955

956956
rb_shape_t *
957-
rb_shape_rebuild_shape(rb_shape_t * initial_shape, rb_shape_t * dest_shape)
957+
rb_shape_rebuild_shape(rb_shape_t *initial_shape, rb_shape_t *dest_shape)
958958
{
959959
RUBY_ASSERT(rb_shape_id(initial_shape) != OBJ_TOO_COMPLEX_SHAPE_ID);
960960
RUBY_ASSERT(rb_shape_id(dest_shape) != OBJ_TOO_COMPLEX_SHAPE_ID);
961961

962-
rb_shape_t * midway_shape;
962+
rb_shape_t *midway_shape;
963963

964964
RUBY_ASSERT(initial_shape->type == SHAPE_T_OBJECT);
965965

@@ -1027,7 +1027,7 @@ rb_shape_memsize(rb_shape_t *shape)
10271027
static VALUE
10281028
rb_shape_too_complex(VALUE self)
10291029
{
1030-
rb_shape_t * shape;
1030+
rb_shape_t *shape;
10311031
shape = rb_shape_get_shape_by_id(NUM2INT(rb_struct_getmember(self, rb_intern("id"))));
10321032
if (rb_shape_id(shape) == OBJ_TOO_COMPLEX_SHAPE_ID) {
10331033
return Qtrue;
@@ -1046,7 +1046,7 @@ parse_key(ID key)
10461046
return LONG2NUM(key);
10471047
}
10481048

1049-
static VALUE rb_shape_edge_name(rb_shape_t * shape);
1049+
static VALUE rb_shape_edge_name(rb_shape_t *shape);
10501050

10511051
static VALUE
10521052
rb_shape_t_to_rb_cShape(rb_shape_t *shape)
@@ -1083,7 +1083,7 @@ rb_shape_edges(VALUE self)
10831083

10841084
if (shape->edges) {
10851085
if (SINGLE_CHILD_P(shape->edges)) {
1086-
rb_shape_t * child = SINGLE_CHILD(shape->edges);
1086+
rb_shape_t *child = SINGLE_CHILD(shape->edges);
10871087
rb_edges_to_hash(child->edge_name, (VALUE)child, &hash);
10881088
}
10891089
else {
@@ -1095,7 +1095,7 @@ rb_shape_edges(VALUE self)
10951095
}
10961096

10971097
static VALUE
1098-
rb_shape_edge_name(rb_shape_t * shape)
1098+
rb_shape_edge_name(rb_shape_t *shape)
10991099
{
11001100
if (shape->edge_name) {
11011101
if (is_instance_id(shape->edge_name)) {
@@ -1117,7 +1117,7 @@ rb_shape_export_depth(VALUE self)
11171117
static VALUE
11181118
rb_shape_parent(VALUE self)
11191119
{
1120-
rb_shape_t * shape;
1120+
rb_shape_t *shape;
11211121
shape = rb_shape_get_shape_by_id(NUM2INT(rb_struct_getmember(self, rb_intern("id"))));
11221122
if (shape->parent_id != INVALID_SHAPE_ID) {
11231123
return rb_shape_t_to_rb_cShape(rb_shape_get_parent(shape));
@@ -1166,7 +1166,7 @@ static VALUE edges(struct rb_id_table* edges)
11661166
{
11671167
VALUE hash = rb_hash_new();
11681168
if (SINGLE_CHILD_P(edges)) {
1169-
rb_shape_t * child = SINGLE_CHILD(edges);
1169+
rb_shape_t *child = SINGLE_CHILD(edges);
11701170
collect_keys_and_values(child->edge_name, (VALUE)child, &hash);
11711171
}
11721172
else {

0 commit comments

Comments
 (0)