jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
alexherbo2 has quit [Ping timeout: 240 seconds]
_whitelogger has joined #crystal-lang
deavmi has quit [Ping timeout: 260 seconds]
deavmi has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Will it optimise out if I `Array#+(Array)` with like 20 arrays
<FromGitter> <Daniel-Worrall> or should I do something like `Array.build`
<FromGitter> <Daniel-Worrall> Basically I have a tree with arrays in their nodes
f1refly has quit [Ping timeout: 240 seconds]
f1reflyylmao has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Maybe I just Array.new(initial_size) and <<
<FromGitter> <Daniel-Worrall> I might not actually need this
Liothen has quit [Quit: Liothen]
sz0 has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <3n-k1> is the XML::Node xpath method supposed to work on the node it's called on, or the root node?
<FromGitter> <3n-k1> docs lead me to think it's the former, but code seems to think otherwise
_whitelogger has joined #crystal-lang
<FromGitter> <j8r> @Daniel-Worrall you probably want `Array#concat`
<FromGitter> <Daniel-Worrall> ty
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <naqvis> @3n-k1 it works on the node, but if you use `/` then XPath traverses from the root
sorcus has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
_whitelogger has joined #crystal-lang
alexherbo2 has joined #crystal-lang
alexherbo29 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo29 is now known as alexherbo2
<FromGitter> <HertzDevil> is there a faster way to get the underlying type of an enum `T` than doing `typeof(T.values.first.value)`?
zorp has joined #crystal-lang
<FromGitter> <Dan-Do> Isn't it Int32?
<FromGitter> <Dan-Do> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f7afc8c1adcf94d3f0092ca]
<FromGitter> <HertzDevil> you can do `Foo : UInt8`
<FromGitter> <HertzDevil> but it isn't the same as `Foo < UInt8`
<FromGitter> <HertzDevil> and `TypeNode` doesn't seem to have anything for this
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
<FromGitter> <Nicolab> @yxhuvud +1
<FromGitter> <3n-k1> @naqvis thanks for letting me know :)
duane has quit [Ping timeout: 256 seconds]
duane has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<oprypin> @HertzDevil: your way is very nice as it is
<FromGitter> <Blacksmoke16> couldnt you just add some method to the enum?
<FromGitter> <Blacksmoke16> ```enum Foo : UInt8 ⏎ def self.type : UInt8.class ⏎ UInt8 ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5f7b3e262bd4875309374a08]
<FromGitter> <Blacksmoke16> `Foo.type`
<FromGitter> <Blacksmoke16> wouldnt be automatic tho
Liothen has joined #crystal-lang
repo1 is now known as repo
<FromGitter> <asterite> @mattrberry so cool that the FPS went from 40 to 100. I'll try to make the compiler be smarter about constants...
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 258 seconds]
<oprypin> 😍
<oprypin> curious to see if it will be about value types or just literals
<FromGitter> <asterite> It's about everything :-)
<FromGitter> <asterite> Essentially: when we are in the codegen phase, whenever we read a constant I'll mark it as "read". If we reach the place where the constant is declare and it wasn't yet read, we can assign that constant's value right there, and accessing it is always reading it. The usual behavior for constants otherwise is to have them be lazily initialized, so reading it always performs a check to see if it was initialized
<FromGitter> ... or not
<FromGitter> <asterite> That goes against modular compilation, but since we don't have that anyway, there's no harm in improving the current situation... who knows when or whether we'll have modular compilation
<FromGitter> <asterite> I think I got it. Looks promising: https://gist.github.com/asterite/b9f4fedfeff6c46137dd1e8e34902f7b
<FromGitter> <asterite> I think they are all the same time, it's just that 1.5ns is too small so if a fly passes by my computer or I cough it can already change :-P
<FromGitter> <asterite> Trying out the const changes double the FPS in crab (well, from 30 to 60). I guess the author also made a bunch of other optimizations
<yxhuvud> asterite: do you need to keep track of the difference between constants that are modified over time (say an array of stuff where the contents get modified) and stuff that are immutable? Or would that be another optimization?
<yxhuvud> really impressive change though :)
<yxhuvud> do you know what triggers the regression of the non-constant values?
<yxhuvud> or is that just random noise?
<FromGitter> <asterite> constant is actually "assigned just once" in crystal
<FromGitter> <asterite> this change doesn't relate to having a mutable array as a constant
<FromGitter> <asterite> so this optimization also applies for mutable arrays assigned to a constant
asterite_ has joined #crystal-lang
lanodan_ has joined #crystal-lang
lanodan has quit [Ping timeout: 244 seconds]
asterite has quit [Ping timeout: 244 seconds]
asterite_ is now known as asterite
Andriamanitra has quit [Ping timeout: 244 seconds]
zorp has quit [Ping timeout: 240 seconds]
lanodan_ is now known as lanodan
<FromGitter> <mattrberry> @asterite That looks really promising!! I did make a number of other optimizations, but the biggest one for me was just inlining the constants. Iirc that’s what brought me from 40->100. Switching to just checking bits instead of casing over ranges bumped me up another 30 or so, and exchanging the stdlib Deque for a much simpler fifo queue got me another ~20
<FromGitter> <mattrberry> Unfortunately I won’t be at my pc until tomorrow night to look more into it, but I’d be really curious if those changes affect CryBoy’s performance at all. I doubt it’d be as significant, but it’d still be interesting to see!
<FromGitter> <mattrberry> And thank you for looking into that, truly awesome to have your insight on this and have these things addressed in the compiler directly (:
<FromGitter> <christopherzimmerman> @asterite I feel like I’ve asked about this before but can’t find the convo, but is there a reason that calling map on a tuple always returns a union type?
_whitelogger has joined #crystal-lang
<FromGitter> <j8r> @christopherzimmerman because of https://github.com/crystal-lang/crystal/blob/719d31487/src/tuple.cr#L66
<FromGitter> <j8r> and also, how would it be possible to yield a value with a different type on each iteration?
<FromGitter> <j8r> *without an union