Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #949 from mattn/find_symbol

Skip end of loop in mrb_sym2name_len
  • Loading branch information...
commit 83c5274a71ea7fc40427029033edc99224e008e0 2 parents f962068 + 9d3a864
@matz matz authored
Showing with 7 additions and 8 deletions.
  1. +7 −8 src/symbol.c
View
15 src/symbol.c
@@ -81,16 +81,15 @@ mrb_sym2name_len(mrb_state *mrb, mrb_sym sym, int *lenp)
for (k = kh_begin(h); k != kh_end(h); k++) {
if (kh_exist(h, k)) {
- if (kh_value(h, k) == sym) break;
+ if (kh_value(h, k) == sym) {
+ sname = kh_key(h, k);
+ *lenp = sname.len;
+ return sname.name;
+ }
}
}
- if (k == kh_end(h)) {
- *lenp = 0;
- return NULL; /* missing */
- }
- sname = kh_key(h, k);
- *lenp = sname.len;
- return sname.name;
+ *lenp = 0;
+ return NULL; /* missing */
}
void
Please sign in to comment.
Something went wrong with that request. Please try again.