News for hackers. Stuff that matters.
Re:My gamedever wishlist for Rust by evincarofautumn on Thursday October 01, 2015 @05:58PM (#10315069)
I don’t even see why a macro would come to mind as a first solution when you can just use a fold.
Re:My gamedever wishlist for Rust by SamReidHughes on Friday October 02, 2015 @12:32AM (#10316748)
That would be horribly slow.
Re:My gamedever wishlist for Rust by evincarofautumn on Friday October 02, 2015 @03:35PM (#10320756)
Would it? Inlining the fold should produce the same code, with no intermediate vector. Granted, such inlining is not guaranteed, whereas with a macro it would be.
Re:My gamedever wishlist for Rust by SamReidHughes on Saturday October 03, 2015 @12:17AM (#10322575)
I don't know about compiler optimization but there's a bit more to it than inlining a fold.
Re:My gamedever wishlist for Rust by SamReidHughes on Saturday October 03, 2015 @10:40PM (#10326203)
I just tried it and sometimes it avoided the vector allocation but at least once it allocated and filled the vector, and then immediately deallocated it. (It didn't reread the data back from the vector.)