Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
Experimenting with rb_str_reserve.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Mar 20, 2017
1 parent 335c54e commit e6b164e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/trenni/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Needed by Ruby 2.1
have_func("rb_sym2str")
have_func("rb_str_cat_cstr")
have_func("rb_str_reserve")

gem_name = File.basename(__dir__)
extension_name = 'trenni'
Expand Down
9 changes: 9 additions & 0 deletions ext/trenni/trenni.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
#define RB_IMMEDIATE_P IMMEDIATE_P
#endif

#ifndef HAVE_RB_STR_RESERVE
inline VALUE rb_str_reserve(VALUE string, long extra) {
long actual = RSTRING_LEN(string);
rb_str_resize(string, actual + extra);
rb_str_set_len(string, actual);
return string;
}
#endif

extern VALUE rb_Trenni, rb_Trenni_Markup, rb_Trenni_Tag, rb_Trenni_MarkupString, rb_Trenni_MarkupString_EMPTY, rb_Trenni_Native, rb_Trenni_ParseError;

extern ID id_cdata, id_open_tag_begin, id_open_tag_end, id_attribute, id_close_tag, id_text, id_doctype, id_comment, id_instruction, id_read, id_expression, id_key_get, id_new, id_name, id_attributes, id_closed, id_to_s, id_is_a;
Expand Down

0 comments on commit e6b164e

Please sign in to comment.