Skip to content

Instantly share code, notes, and snippets.

@Philonous
Created May 14, 2021 18:42
Show Gist options
  • Save Philonous/071f8fda7dfab057b9bbc35980b71d3a to your computer and use it in GitHub Desktop.
Save Philonous/071f8fda7dfab057b9bbc35980b71d3a to your computer and use it in GitHub Desktop.
SmallArray#-based toArecFast
-- RHS size: {terms: 166, types: 1,141, coercions: 387, joins: 0/1}
$wmkToARecFast
:: Int#
-> ARec
ElField
'[ '("a0", Int), '("a1", Int), '("a2", Int), '("a3", Int),
'("a4", Int), '("a5", Int), '("a6", Int), '("a7", Int),
'("a8", Int), '("a9", Int), '("a10", Int), '("a11", Int),
'("a12", Int), '("a13", Int), '("a14", Int), '("a15", Int)]
$wmkToARecFast
= \ (ww :: Int#) ->
case runRW#
(\ (st0 :: State# RealWorld) ->
case newSmallArray# 16# mkARec3 st0 of { (# ipv, ipv1 #) ->
let {
dt :: Int
dt = I# ww } in
case writeSmallArray#
ipv1
0#
((Field @~ <Co:6> ($s$WField1 `cast` <Co:7>) dt) `cast` <Co:12>)
ipv
of st1
{ __DEFAULT ->
case writeSmallArray#
ipv1
1#
((Field @~ <Co:6> ($s$WField4 `cast` <Co:7>) dt) `cast` <Co:12>)
st1
of st2
{ __DEFAULT ->
case writeSmallArray#
ipv1
2#
((Field @~ <Co:6> ($s$WField7 `cast` <Co:7>) dt) `cast` <Co:12>)
st2
of st3
{ __DEFAULT ->
case writeSmallArray#
ipv1
3#
((Field @~ <Co:6> ($s$WField10 `cast` <Co:7>) dt) `cast` <Co:12>)
st3
of st4
{ __DEFAULT ->
case writeSmallArray#
ipv1
4#
((Field @~ <Co:6> ($s$WField13 `cast` <Co:7>) dt) `cast` <Co:12>)
st4
of st5
{ __DEFAULT ->
case writeSmallArray#
ipv1
5#
((Field @~ <Co:6> ($s$WField16 `cast` <Co:7>) dt) `cast` <Co:12>)
st5
of st6
{ __DEFAULT ->
case writeSmallArray#
ipv1
6#
((Field @~ <Co:6> ($s$WField19 `cast` <Co:7>) dt) `cast` <Co:12>)
st6
of st7
{ __DEFAULT ->
case writeSmallArray#
ipv1
7#
((Field @~ <Co:6> ($s$WField22 `cast` <Co:7>) dt) `cast` <Co:12>)
st7
of st8
{ __DEFAULT ->
case writeSmallArray#
ipv1
8#
((Field @~ <Co:6> ($s$WField25 `cast` <Co:7>) dt) `cast` <Co:12>)
st8
of st9
{ __DEFAULT ->
case writeSmallArray#
ipv1
9#
((Field @~ <Co:6> ($s$WField28 `cast` <Co:7>) dt) `cast` <Co:12>)
st9
of st10
{ __DEFAULT ->
case writeSmallArray#
ipv1
10#
((Field @~ <Co:6> ($s$WField31 `cast` <Co:7>) dt) `cast` <Co:12>)
st10
of st11
{ __DEFAULT ->
case writeSmallArray#
ipv1
11#
((Field @~ <Co:6> ($s$WField34 `cast` <Co:7>) dt) `cast` <Co:12>)
st11
of st12
{ __DEFAULT ->
case writeSmallArray#
ipv1
12#
((Field @~ <Co:6> ($s$WField37 `cast` <Co:7>) dt) `cast` <Co:12>)
st12
of st13
{ __DEFAULT ->
case writeSmallArray#
ipv1
13#
((Field @~ <Co:6> ($s$WField40 `cast` <Co:7>) dt) `cast` <Co:12>)
st13
of st14
{ __DEFAULT ->
case writeSmallArray#
ipv1
14#
((Field @~ <Co:6> ($s$WField43 `cast` <Co:7>) dt) `cast` <Co:12>)
st14
of st15
{ __DEFAULT ->
case writeSmallArray# ipv1 15# (mkARec1 `cast` <Co:12>) st15
of st16
{ __DEFAULT ->
case unsafeFreezeSmallArray# ipv1 st16 of { (# ipv4, ipv5 #) ->
(# ipv4, ARec ipv5 #)
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
})
of
{ (# ipv, ipv1 #) ->
ipv1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment