[DiscordArchive] the algorithm still works?
[DiscordArchive] the algorithm still works?
Archived author: schlumpf • Posted: 2018-05-30T08:46:51.721000+00:00
Original source
the algorithm still works?
![[Image: is_it_worth_the_time.png?ex=690c608c&is=...4d93e2a7c&]](https://cdn.discordapp.com/attachments/408013572430626817/451305553105387520/is_it_worth_the_time.png?ex=690c608c&is=690b0f0c&hm=6b380cfc40314c84b53c738900d295e12e1d715269d1534a8e3e1664d93e2a7c&)
Archived author: schlumpf • Posted: 2018-05-30T08:47:08.712000+00:00
Original source
also, this is a once per week job.
![[Image: is_it_worth_the_time.png?ex=690c608c&is=...4d93e2a7c&]](https://cdn.discordapp.com/attachments/408013572430626817/451305553105387520/is_it_worth_the_time.png?ex=690c608c&is=690b0f0c&hm=6b380cfc40314c84b53c738900d295e12e1d715269d1534a8e3e1664d93e2a7c&)
Archived author: Maku • Posted: 2018-05-30T08:47:17.222000+00:00
Original source
Yeah, but maybe there's some arcane C# fuckery that does that
Archived author: Maku • Posted: 2018-05-30T08:47:24.468000+00:00
Original source
So we don't have to do it at all
Archived author: Warpten • Posted: 2018-05-30T08:52:16.242000+00:00
Original source
<@128154136020647936> Access the underlying buffer (there may not always be one, it's not a strong guarantee, but there usually is), get a fixed pointer to it and do your lookup in an unsafe block
Archived author: Maku • Posted: 2018-05-30T08:58:41.830000+00:00
Original source
Okay, no wizardry available, thanks!
Archived author: Warpten • Posted: 2018-05-30T08:59:29.538000+00:00
Original source
Would do it that way personally because I already have plain c code that does it so with minor adjustments I can just copy/paste. Nice types are nice but sometimes raw pointers are just better.
```cs
fixed (byte* b = stream.GetBuffer())
return *(int*)do_weird_lookup(b);
```
For example
Archived author: Warpten • Posted: 2018-05-30T09:00:23.343000+00:00
Original source
I mean you go with a dumb for loop or wrap around and use a binary reader around your stream but you'd kill performance since binaryreader has a small buffer and when you read byte[] it copies
Archived author: Warpten • Posted: 2018-05-30T09:01:02.693000+00:00
Original source
(am on the phone, excuse formatting)
Archived author: Maku • Posted: 2018-05-30T09:01:11.502000+00:00
Original source
no worries