Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upOption<char> should be represented as just one 32 bit value #5977
Comments
This comment has been minimized.
This comment has been minimized.
|
In the same vein as #6791. Is a reasonable optimization but probably not critical. We do similar optimizations for pointer types, I think. |
This comment has been minimized.
This comment has been minimized.
|
Okay, this would mean representing |
This comment has been minimized.
This comment has been minimized.
|
Once #8974 lands, we can go ahead with this. |
This comment has been minimized.
This comment has been minimized.
|
If the compiler knew about possible values a type could take perhaps it could make these optimizations automatically? E.g. an ASCII character can have values in the range 0-127, so enum T {
On,
Off
}
enum Repeats {
Zero
One(T),
Two(T,T),
Three(T,T,T)
Four(T,T,T,T)
Five(T,T,T,T,T)
}Because |
This comment has been minimized.
This comment has been minimized.
|
@Thiez what happens for: match repeats {
Five(ref x, _, _, _, _) => {}
_ => {}
}it'd have to be able to handle sub-word references. |
This comment has been minimized.
This comment has been minimized.
|
This will only work for |
This comment has been minimized.
This comment has been minimized.
|
I think it would work for any enum with up to 2047 nullary variants and one variant containing a |
This comment has been minimized.
This comment has been minimized.
|
If you set any of the bits in the |
This comment has been minimized.
This comment has been minimized.
|
Can this case be extended to |
This comment has been minimized.
This comment has been minimized.
|
@thestinger: Yes. But if you have:
You can freely use up to 11 bits to represent which variant it is, with the restriction that zero is reserved for |
This comment has been minimized.
This comment has been minimized.
|
We now have range asserts on |
This comment has been minimized.
This comment has been minimized.
|
Similar to #14540. |
cmr
self-assigned this
Mar 25, 2015
cmr
removed their assignment
Jan 5, 2016
This comment has been minimized.
This comment has been minimized.
|
If someone can mentor me through this bug, I'd be interested in giving it a try. |
This comment has been minimized.
This comment has been minimized.
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 26, 2016
Yoric
referenced this issue
Jan 26, 2016
Closed
Issue #5977 - Generalizing RawNullablePointer to RawForbiddenValue #31215
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 26, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 26, 2016
Yoric
referenced this issue
Jan 27, 2016
Open
Optimize Option<f64> and friends with nanboxing #31236
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 27, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 27, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 27, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 27, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 29, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 29, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 29, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Jan 29, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Feb 2, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Feb 2, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Feb 2, 2016
pushed a commit
to Yoric/rust
that referenced
this issue
Feb 3, 2016
This comment has been minimized.
This comment has been minimized.
added a commit
to mrhota/rust
that referenced
this issue
Sep 3, 2016
added a commit
to mrhota/rust
that referenced
this issue
Sep 3, 2016
added a commit
to mrhota/rust
that referenced
this issue
Sep 3, 2016
added a commit
to mrhota/rust
that referenced
this issue
Sep 3, 2016
mrhota
referenced this issue
Sep 3, 2016
Closed
Represent Option<bool> and Option<char> as 8bit and 32bit values #36237
This comment has been minimized.
This comment has been minimized.
|
For anyone wanting to see the status of this, here's code you can run: fn main() {
println!("{}", ::std::mem::size_of::<Option<char>>());
}it currently prints '8' (bytes) |
Kimundi commentedApr 20, 2013
A
charis au32, but Unicode is standardized to only take up 21bit, so there is more than enough space for that optimization.Might be useful for specifying code page conversion tables with holes in them.