Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tupled definitions preventing inlining #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 94 additions & 55 deletions lib/bigstringaf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -237,43 +237,64 @@ module Swap = struct
((caml_bigstring_get_16 x off) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16)
end

let set_int16_le, set_int16_be =
if Sys.big_endian
then Swap.caml_bigstring_set_16, caml_bigstring_set_16
else caml_bigstring_set_16 , Swap.caml_bigstring_set_16

let set_int32_le, set_int32_be =
if Sys.big_endian
then Swap.caml_bigstring_set_32, caml_bigstring_set_32
else caml_bigstring_set_32 , Swap.caml_bigstring_set_32

let set_int64_le, set_int64_be =
if Sys.big_endian
then Swap.caml_bigstring_set_64, caml_bigstring_set_64
else caml_bigstring_set_64 , Swap.caml_bigstring_set_64

let get_int16_le, get_int16_be =
if Sys.big_endian
then Swap.caml_bigstring_get_16, caml_bigstring_get_16
else caml_bigstring_get_16 , Swap.caml_bigstring_get_16
let set_int16_le b i x =
if Sys.big_endian then Swap.caml_bigstring_set_16 b i x
else caml_bigstring_set_16 b i x

let set_int16_be b i x =
if not Sys.big_endian then Swap.caml_bigstring_set_16 b i x
else caml_bigstring_set_16 b i x

let set_int32_le b i x =
if Sys.big_endian then Swap.caml_bigstring_set_32 b i x
else caml_bigstring_set_32 b i x

let set_int32_be b i x =
if not Sys.big_endian then Swap.caml_bigstring_set_32 b i x
else caml_bigstring_set_32 b i x

let set_int64_le b i x =
if Sys.big_endian then Swap.caml_bigstring_set_64 b i x
else caml_bigstring_set_64 b i x

let set_int64_be b i x =
if not Sys.big_endian then Swap.caml_bigstring_set_64 b i x
else caml_bigstring_set_64 b i x

let get_int16_le b i =
if Sys.big_endian then Swap.caml_bigstring_get_16 b i
else caml_bigstring_get_16 b i

let get_int16_be b i =
if not Sys.big_endian then Swap.caml_bigstring_get_16 b i
else caml_bigstring_get_16 b i

let get_int16_sign_extended_noswap x off =
((caml_bigstring_get_16 x off) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16)

let get_int16_sign_extended_le, get_int16_sign_extended_be =
if Sys.big_endian
then Swap.get_int16_sign_extended , get_int16_sign_extended_noswap
else get_int16_sign_extended_noswap, Swap.get_int16_sign_extended
let get_int16_sign_extended_le b i =
if Sys.big_endian then Swap.get_int16_sign_extended b i
else get_int16_sign_extended_noswap b i

let get_int16_sign_extended_be b i =
if not Sys.big_endian then Swap.get_int16_sign_extended b i
else get_int16_sign_extended_noswap b i

let get_int32_le, get_int32_be =
if Sys.big_endian
then Swap.caml_bigstring_get_32, caml_bigstring_get_32
else caml_bigstring_get_32 , Swap.caml_bigstring_get_32
let get_int32_le b i =
if Sys.big_endian then Swap.caml_bigstring_get_32 b i
else caml_bigstring_get_32 b i

let get_int64_le, get_int64_be =
if Sys.big_endian
then Swap.caml_bigstring_get_64, caml_bigstring_get_64
else caml_bigstring_get_64 , Swap.caml_bigstring_get_64
let get_int32_be b i =
if not Sys.big_endian then Swap.caml_bigstring_get_32 b i
else caml_bigstring_get_32 b i

let get_int64_le b i =
if Sys.big_endian then Swap.caml_bigstring_get_64 b i
else caml_bigstring_get_64 b i

let get_int64_be b i =
if not Sys.big_endian then Swap.caml_bigstring_get_64 b i
else caml_bigstring_get_64 b i

(* Unsafe operations *)

Expand Down Expand Up @@ -309,38 +330,56 @@ module USwap = struct
bswap_int64 (caml_bigstring_unsafe_get_64 bs off)
end

let unsafe_set_int16_le, unsafe_set_int16_be =
if Sys.big_endian
then USwap.caml_bigstring_unsafe_set_16, caml_bigstring_unsafe_set_16
else caml_bigstring_unsafe_set_16 , USwap.caml_bigstring_unsafe_set_16
let unsafe_set_int16_le b i x =
if Sys.big_endian then USwap.caml_bigstring_unsafe_set_16 b i x
else caml_bigstring_unsafe_set_16 b i x

let unsafe_set_int16_be b i x =
if not Sys.big_endian then USwap.caml_bigstring_unsafe_set_16 b i x
else caml_bigstring_unsafe_set_16 b i x

let unsafe_set_int32_le b i x =
if Sys.big_endian then USwap.caml_bigstring_unsafe_set_32 b i x
else caml_bigstring_unsafe_set_32 b i x

let unsafe_set_int32_le, unsafe_set_int32_be =
if Sys.big_endian
then USwap.caml_bigstring_unsafe_set_32, caml_bigstring_unsafe_set_32
else caml_bigstring_unsafe_set_32 , USwap.caml_bigstring_unsafe_set_32
let unsafe_set_int32_be b i x =
if not Sys.big_endian then USwap.caml_bigstring_unsafe_set_32 b i x
else caml_bigstring_unsafe_set_32 b i x

let unsafe_set_int64_le, unsafe_set_int64_be =
if Sys.big_endian
then USwap.caml_bigstring_unsafe_set_64, caml_bigstring_unsafe_set_64
else caml_bigstring_unsafe_set_64 , USwap.caml_bigstring_unsafe_set_64
let unsafe_set_int64_le b i x =
if Sys.big_endian then USwap.caml_bigstring_unsafe_set_64 b i x
else caml_bigstring_unsafe_set_64 b i x

let unsafe_get_int16_le, unsafe_get_int16_be =
if Sys.big_endian
then USwap.caml_bigstring_unsafe_get_16, caml_bigstring_unsafe_get_16
else caml_bigstring_unsafe_get_16 , USwap.caml_bigstring_unsafe_get_16
let unsafe_set_int64_be b i x =
if not Sys.big_endian then USwap.caml_bigstring_unsafe_set_64 b i x
else caml_bigstring_unsafe_set_64 b i x

let unsafe_get_int16_le b i =
if Sys.big_endian then USwap.caml_bigstring_unsafe_get_16 b i
else caml_bigstring_unsafe_get_16 b i

let unsafe_get_int16_be b i =
if not Sys.big_endian then USwap.caml_bigstring_unsafe_get_16 b i
else caml_bigstring_unsafe_get_16 b i

let unsafe_get_int16_sign_extended_le x off =
((unsafe_get_int16_le x off) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16)

let unsafe_get_int16_sign_extended_be x off =
((unsafe_get_int16_be x off ) lsl (Sys.int_size - 16)) asr (Sys.int_size - 16)

let unsafe_get_int32_le, unsafe_get_int32_be =
if Sys.big_endian
then USwap.caml_bigstring_unsafe_get_32, caml_bigstring_unsafe_get_32
else caml_bigstring_unsafe_get_32 , USwap.caml_bigstring_unsafe_get_32
let unsafe_get_int32_le b i =
if Sys.big_endian then USwap.caml_bigstring_unsafe_get_32 b i
else caml_bigstring_unsafe_get_32 b i

let unsafe_get_int32_be b i =
if not Sys.big_endian then USwap.caml_bigstring_unsafe_get_32 b i
else caml_bigstring_unsafe_get_32 b i

let unsafe_get_int64_le b i =
if Sys.big_endian then USwap.caml_bigstring_unsafe_get_64 b i
else caml_bigstring_unsafe_get_64 b i

let unsafe_get_int64_le, unsafe_get_int64_be =
if Sys.big_endian
then USwap.caml_bigstring_unsafe_get_64, caml_bigstring_unsafe_get_64
else caml_bigstring_unsafe_get_64 , USwap.caml_bigstring_unsafe_get_64
let unsafe_get_int64_be b i =
if not Sys.big_endian then USwap.caml_bigstring_unsafe_get_64 b i
else caml_bigstring_unsafe_get_64 b i