mirror of
https://github.com/mattrberry/crab.git
synced 2025-02-09 08:46:02 +01:00
turn off slice bounds checking in release mode
This change removes bounds checking for Slices, which represents most indexable storage in the emulator. Removing these checks makes the emulator less safe, without a doubt. However, it amounts a roughly 5% improvement in the games tested. Most of the checks today occur in fixed-length arrays where the index cannot be out of bounds, so I'm chosing to make this tradeoff.
This commit is contained in:
parent
e0ef57d9e6
commit
d864b27e35
1 changed files with 16 additions and 0 deletions
16
src/crab.cr
16
src/crab.cr
|
@ -1,3 +1,19 @@
|
|||
{% if flag?(:release) %}
|
||||
# Disables bounds checking in release mode.
|
||||
|
||||
struct Slice(T)
|
||||
@[AlwaysInline]
|
||||
def []=(index : Int, value : T) : T
|
||||
@pointer[index] = value
|
||||
end
|
||||
|
||||
@[AlwaysInline]
|
||||
def [](index : Int) : T
|
||||
@pointer[index]
|
||||
end
|
||||
end
|
||||
{% end %}
|
||||
|
||||
require "colorize"
|
||||
require "option_parser"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue