cache index resolution

resolve once and reuse
also use non checking version of get/set
as index per definition must be ok
This creates some speedup, but mostly avoids some weird hang in Thread::Queue.pop for many seconds
This commit is contained in:
Torsten Ruger
2018-08-12 13:09:34 +03:00
parent 84de400529
commit 66e0d4ae26
2 changed files with 24 additions and 21 deletions

View File

@ -18,17 +18,23 @@ module Risc
end
def set(index , value)
range_check(index)
_set(index,value)
end
alias :[]= :set
def _set(index , value)
@memory[index] = value
value
end
alias :[]= :set
def get(index)
range_check(index)
@memory[index]
_get(index)
end
alias :[] :get
def _get(index)
@memory[index]
end
def size
@memory.length
end