@@ -1016,16 +1016,13 @@ json_object_i(VALUE key, VALUE val, VALUE _arg)
1016
1016
JSON_Generator_State * state = data -> state ;
1017
1017
1018
1018
long depth = state -> depth ;
1019
- int j ;
1020
1019
1021
1020
if (arg -> iter > 0 ) fbuffer_append_char (buffer , ',' );
1022
1021
if (RB_UNLIKELY (data -> state -> object_nl )) {
1023
1022
fbuffer_append_str (buffer , data -> state -> object_nl );
1024
1023
}
1025
1024
if (RB_UNLIKELY (data -> state -> indent )) {
1026
- for (j = 0 ; j < depth ; j ++ ) {
1027
- fbuffer_append_str (buffer , data -> state -> indent );
1028
- }
1025
+ fbuffer_append_str_repeat (buffer , data -> state -> indent , depth );
1029
1026
}
1030
1027
1031
1028
VALUE key_to_s ;
@@ -1083,7 +1080,6 @@ static inline long increase_depth(struct generate_json_data *data)
1083
1080
1084
1081
static void generate_json_object (FBuffer * buffer , struct generate_json_data * data , VALUE obj )
1085
1082
{
1086
- int j ;
1087
1083
long depth = increase_depth (data );
1088
1084
1089
1085
if (RHASH_SIZE (obj ) == 0 ) {
@@ -1104,17 +1100,14 @@ static void generate_json_object(FBuffer *buffer, struct generate_json_data *dat
1104
1100
if (RB_UNLIKELY (data -> state -> object_nl )) {
1105
1101
fbuffer_append_str (buffer , data -> state -> object_nl );
1106
1102
if (RB_UNLIKELY (data -> state -> indent )) {
1107
- for (j = 0 ; j < depth ; j ++ ) {
1108
- fbuffer_append_str (buffer , data -> state -> indent );
1109
- }
1103
+ fbuffer_append_str_repeat (buffer , data -> state -> indent , depth );
1110
1104
}
1111
1105
}
1112
1106
fbuffer_append_char (buffer , '}' );
1113
1107
}
1114
1108
1115
1109
static void generate_json_array (FBuffer * buffer , struct generate_json_data * data , VALUE obj )
1116
1110
{
1117
- int i , j ;
1118
1111
long depth = increase_depth (data );
1119
1112
1120
1113
if (RARRAY_LEN (obj ) == 0 ) {
@@ -1125,25 +1118,21 @@ static void generate_json_array(FBuffer *buffer, struct generate_json_data *data
1125
1118
1126
1119
fbuffer_append_char (buffer , '[' );
1127
1120
if (RB_UNLIKELY (data -> state -> array_nl )) fbuffer_append_str (buffer , data -> state -> array_nl );
1128
- for (i = 0 ; i < RARRAY_LEN (obj ); i ++ ) {
1121
+ for (int i = 0 ; i < RARRAY_LEN (obj ); i ++ ) {
1129
1122
if (i > 0 ) {
1130
1123
fbuffer_append_char (buffer , ',' );
1131
1124
if (RB_UNLIKELY (data -> state -> array_nl )) fbuffer_append_str (buffer , data -> state -> array_nl );
1132
1125
}
1133
1126
if (RB_UNLIKELY (data -> state -> indent )) {
1134
- for (j = 0 ; j < depth ; j ++ ) {
1135
- fbuffer_append_str (buffer , data -> state -> indent );
1136
- }
1127
+ fbuffer_append_str_repeat (buffer , data -> state -> indent , depth );
1137
1128
}
1138
1129
generate_json (buffer , data , RARRAY_AREF (obj , i ));
1139
1130
}
1140
1131
data -> state -> depth = -- depth ;
1141
1132
if (RB_UNLIKELY (data -> state -> array_nl )) {
1142
1133
fbuffer_append_str (buffer , data -> state -> array_nl );
1143
1134
if (RB_UNLIKELY (data -> state -> indent )) {
1144
- for (j = 0 ; j < depth ; j ++ ) {
1145
- fbuffer_append_str (buffer , data -> state -> indent );
1146
- }
1135
+ fbuffer_append_str_repeat (buffer , data -> state -> indent , depth );
1147
1136
}
1148
1137
}
1149
1138
fbuffer_append_char (buffer , ']' );
0 commit comments