diff options
author | Chris Fallin <cfallin@google.com> | 2015-05-19 15:33:48 -0700 |
---|---|---|
committer | Chris Fallin <cfallin@google.com> | 2015-05-19 16:19:00 -0700 |
commit | 231886f6327b7cad480b96d08595f45b3526cb4a (patch) | |
tree | a20711cf778f1f0d516d4648991a997963fe24f9 /ruby/ext/google/protobuf_c/repeated_field.c | |
parent | a8b38c598d7f65b281a72809b28117afdb760931 (diff) | |
download | protobuf-231886f6327b7cad480b96d08595f45b3526cb4a.tar.gz protobuf-231886f6327b7cad480b96d08595f45b3526cb4a.tar.bz2 protobuf-231886f6327b7cad480b96d08595f45b3526cb4a.zip |
Ruby C extension speedup: don't re-intern constant string needlessly.
Also fixed lines with > 80 char length.
Diffstat (limited to 'ruby/ext/google/protobuf_c/repeated_field.c')
-rw-r--r-- | ruby/ext/google/protobuf_c/repeated_field.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ruby/ext/google/protobuf_c/repeated_field.c b/ruby/ext/google/protobuf_c/repeated_field.c index dc1d0355..ffa60c15 100644 --- a/ruby/ext/google/protobuf_c/repeated_field.c +++ b/ruby/ext/google/protobuf_c/repeated_field.c @@ -117,7 +117,8 @@ VALUE RepeatedField_index(int argc, VALUE* argv, VALUE _self) { if (index < 0 || index >= self->size) { return Qnil; } - void* memory = (void *) (((uint8_t *)self->elements) + index * element_size); + void* memory = (void *) (((uint8_t *)self->elements) + + index * element_size); return native_slot_get(field_type, field_type_class, memory); }else{ /* check if idx is Range */ @@ -497,13 +498,13 @@ VALUE RepeatedField_concat(VALUE _self, VALUE list) { void validate_type_class(upb_fieldtype_t type, VALUE klass) { - if (rb_iv_get(klass, kDescriptorInstanceVar) == Qnil) { + if (rb_ivar_get(klass, descriptor_instancevar_interned) == Qnil) { rb_raise(rb_eArgError, "Type class has no descriptor. Please pass a " "class or enum as returned by the DescriptorPool."); } if (type == UPB_TYPE_MESSAGE) { - VALUE desc = rb_iv_get(klass, kDescriptorInstanceVar); + VALUE desc = rb_ivar_get(klass, descriptor_instancevar_interned); if (!RB_TYPE_P(desc, T_DATA) || !RTYPEDDATA_P(desc) || RTYPEDDATA_TYPE(desc) != &_Descriptor_type) { rb_raise(rb_eArgError, "Descriptor has an incorrect type."); @@ -513,7 +514,7 @@ void validate_type_class(upb_fieldtype_t type, VALUE klass) { "Message class was not returned by the DescriptorPool."); } } else if (type == UPB_TYPE_ENUM) { - VALUE enumdesc = rb_iv_get(klass, kDescriptorInstanceVar); + VALUE enumdesc = rb_ivar_get(klass, descriptor_instancevar_interned); if (!RB_TYPE_P(enumdesc, T_DATA) || !RTYPEDDATA_P(enumdesc) || RTYPEDDATA_TYPE(enumdesc) != &_EnumDescriptor_type) { rb_raise(rb_eArgError, "Descriptor has an incorrect type."); |