Skip to content

Commit

Permalink
Refactor branching to assignment
Browse files Browse the repository at this point in the history
Cherry-picked from #479
  • Loading branch information
juanxo authored and sodabrew committed Feb 23, 2015
1 parent e78d496 commit ba5c5a0
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions ext/mysql2/result.c
Expand Up @@ -446,7 +446,7 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
mysql2_result_wrapper * wrapper;
unsigned long i;
const char * errstr;
int symbolizeKeys = 0, asArray = 0, castBool = 0, cacheRows = 1, cast = 1;
int symbolizeKeys, asArray, castBool, cacheRows, cast;
MYSQL_FIELD * fields = NULL;

GetMysql2Result(self, wrapper);
Expand All @@ -459,25 +459,11 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
opts = defaults;
}

if (rb_hash_aref(opts, sym_symbolize_keys) == Qtrue) {
symbolizeKeys = 1;
}

if (rb_hash_aref(opts, sym_as) == sym_array) {
asArray = 1;
}

if (rb_hash_aref(opts, sym_cast_booleans) == Qtrue) {
castBool = 1;
}

if (rb_hash_aref(opts, sym_cache_rows) == Qfalse) {
cacheRows = 0;
}

if (rb_hash_aref(opts, sym_cast) == Qfalse) {
cast = 0;
}
symbolizeKeys = RTEST(rb_hash_aref(opts, sym_symbolize_keys));
asArray = rb_hash_aref(opts, sym_as) == sym_array;
castBool = RTEST(rb_hash_aref(opts, sym_cast_booleans));
cacheRows = RTEST(rb_hash_aref(opts, sym_cache_rows));
cast = RTEST(rb_hash_aref(opts, sym_cast));

if (wrapper->is_streaming && cacheRows) {
rb_warn("cacheRows is ignored if streaming is true");
Expand Down

0 comments on commit ba5c5a0

Please sign in to comment.