Guest User

Untitled

a guest
Feb 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. diff --git a/vm/instructions.rb b/vm/instructions.rb
  2. index 92c9c0c..9f2d349 100644
  3. --- a/vm/instructions.rb
  4. +++ b/vm/instructions.rb
  5. @@ -3829,23 +3829,10 @@ class Instructions
  6. def shift_array
  7. <<-CODE
  8. Array* array = as<Array>(stack_pop());
  9. - size_t size = (size_t)array->size();
  10.  
  11. - if(size == 0) {
  12. - stack_push(array);
  13. - stack_push(Qnil);
  14. - } else {
  15. - size_t j = size - 1;
  16. - Object* shifted_value = array->get(state, 0);
  17. - Array* smaller_array = Array::create(state, j);
  18. -
  19. - for(size_t i = 0; i < j; i++) {
  20. - smaller_array->set(state, i, array->get(state, i+1));
  21. - }
  22. -
  23. - stack_push(smaller_array);
  24. - stack_push(shifted_value);
  25. - }
  26. + Object *val = array->shift(state);
  27. + stack_push(array);
  28. + stack_push(val);
  29. CODE
  30. end
Add Comment
Please, Sign In to add comment