Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix for benchmark

  • Loading branch information...
commit 8c353c296fccba5b86a0ed570c5fe937f503f45e 1 parent 429fe01
Hanfei Shen authored

Showing 1 changed file with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. +6 6 ext/rocketamf_ext/class_mapping.c
12 ext/rocketamf_ext/class_mapping.c
@@ -347,14 +347,14 @@ static int mapping_populate_iter(VALUE key, VALUE val, const VALUE args[2]) {
347 347 return ST_CONTINUE;
348 348 }
349 349
350   - if(TYPE(key) != T_SYMBOL) rb_raise(rb_eArgError, "Invalid type for property key: %d", TYPE(key));
  350 + if(TYPE(key) != T_SYMBOL && TYPE(key) != T_STRING) rb_raise(rb_eArgError, "Invalid type for property key: %s", rb_obj_classname(key));
  351 + if(TYPE(key) == T_SYMBOL) key = rb_sym_to_s(key);
351 352
352 353 // Calculate symbol for setter function
353   - ID key_id = SYM2ID(key);
354 354 ID setter_id;
355   - if(!st_lookup(map->setter_cache, key_id, &setter_id)) {
  355 + if(!st_lookup(map->setter_cache, key, &setter_id)) {
356 356 // Calculate symbol
357   - const char* key_str = rb_id2name(key_id);
  357 + const char* key_str = RSTRING_PTR(key);
358 358 long len = strlen(key_str);
359 359 char* setter = ALLOC_N(char, len+2);
360 360 memcpy(setter, key_str, len);
@@ -364,7 +364,7 @@ static int mapping_populate_iter(VALUE key, VALUE val, const VALUE args[2]) {
364 364 xfree(setter);
365 365
366 366 // Store it
367   - st_add_direct(map->setter_cache, key_id, setter_id);
  367 + st_add_direct(map->setter_cache, key, setter_id);
368 368 }
369 369
370 370 if(rb_respond_to(obj, setter_id)) {
@@ -481,4 +481,4 @@ void Init_rocket_amf_fast_class_mapping() {
481 481 id_mappings = rb_intern("mappings");
482 482 id_mappings_ivar = rb_intern("@mappings");
483 483 id_hashset = rb_intern("[]=");
484   -}
  484 +}

0 comments on commit 8c353c2

Please sign in to comment.
Something went wrong with that request. Please try again.