mirror of
https://github.com/faye/faye-websocket-ruby.git
synced 2025-11-01 13:59:13 +00:00
Cast mask numbers to C ints once.
This commit is contained in:
@@ -16,11 +16,16 @@ void Init_faye_websocket_mask() {
|
||||
|
||||
VALUE method_faye_websocket_mask(VALUE self, VALUE payload, VALUE mask) {
|
||||
int n = RARRAY_LEN(payload), i, p, m;
|
||||
int mask_array[4];
|
||||
VALUE unmasked = rb_ary_new2(n);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
mask_array[i] = NUM2INT(rb_ary_entry(mask, i));
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
p = NUM2INT(rb_ary_entry(payload, i));
|
||||
m = NUM2INT(rb_ary_entry(mask, i % 4));
|
||||
m = mask_array[i % 4];
|
||||
rb_ary_store(unmasked, i, INT2NUM(p ^ m));
|
||||
}
|
||||
return unmasked;
|
||||
|
||||
Reference in New Issue
Block a user