Class: String

Inherits:
Object show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#fast_xsObject



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'ext/fast_xs/fast_xs.c', line 166

VALUE fast_xs(VALUE self)
{
	long i;
	struct RArray *array;
	char *s, *c;
	long s_len = 0;
	VALUE *tmp;

	array = RARRAY(rb_rescue(unpack_utf8, self, unpack_uchar, self));

	tmp = RARRAY_PTR(array);
	for (i = RARRAY_LEN(array); --i >= 0; tmp++)
		s_len += escaped_len(NUM2INT(*tmp));

	c = s = alloca(s_len + 1);

	tmp = RARRAY_PTR(array);
	for (i = RARRAY_LEN(array); --i >= 0; tmp++)
		c += escape(c, NUM2INT(*tmp));

	*c = '\0';
	return rb_str_new(s, s_len);
}