langurmonkey/website-source
1
2
Fork
You've already forked website-source
1

fix(rust-memorymap): only use BufReader when necessary in example #1

Merged
langurmonkey merged 1 commit from ErichDonGubler/langurmonkey-website-source:fix-bufread-in-memorymap into master 2022年11月26日 08:34:07 +01:00
Contributor
Copy link

The Reading memory mapped text files example actually pessimizes the case where a non-GZipped file is being read. It's only necessary to do this for flate2::bufread::GzDecoder, and not the &[u8] that's being given by the expression &mmap[..]; &[u8] already implements BufRead!


For further fun, you might be interested in eliminating the unnecessary Boxing done here tool using @llogiq's stack allocation trick, but I can see how that might hurt the example's readability.

The `Reading memory mapped text files` example actually _pessimizes_ the case where a non-GZipped file is being read. It's only necessary to do this for `flate2::bufread::GzDecoder`, and not the `&[u8]` that's being given by the expression `&mmap[..]`; `&[u8]` already [implements][docs] `BufRead`! [docs]: https://doc.rust-lang.org/stable/std/io/trait.BufRead.html#implementors --- For further fun, you might be interested in eliminating the unnecessary `Box`ing done here tool using [@llogiq's stack allocation trick](https://llogiq.github.io/2020/03/14/ootb.html), but I can see how that might hurt the example's readability.
The `Reading memory mapped text files` example actually _pessimizes_ the case where a non-GZipped
file is being read. It's only necessary to do this for `flate2::bufread::GzDecoder`, and not the
`&[u8]` that's being given by the expression `&mmap[..]`; `&[u8]` already [implements][docs]
`BufRead`!
[docs]: https://doc.rust-lang.org/stable/std/io/trait.BufRead.html#implementors 

Thanks for the correction!

Thanks for the correction!

Also fixed this in the original sources of gaiasky-catgen.

Also fixed this in the original sources of `gaiasky-catgen`.
ErichDonGubler deleted branch fix-bufread-in-memorymap 2024年08月26日 03:09:48 +02:00
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
langurmonkey/website-source!1
Reference in a new issue
langurmonkey/website-source
No description provided.
Delete branch "ErichDonGubler/langurmonkey-website-source:fix-bufread-in-memorymap"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?