mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Encode ScalarInt::bytes
as u128
instead of [u8; 16]
to see if that caused the performance regression
This commit is contained in:
parent
362123dd75
commit
eac309984f
@ -3,6 +3,7 @@ use crate::throw_ub;
|
||||
use rustc_apfloat::ieee::{Double, Single};
|
||||
use rustc_apfloat::Float;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
use rustc_target::abi::{Size, TargetDataLayout};
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::fmt;
|
||||
@ -115,7 +116,7 @@ impl std::fmt::Debug for ConstInt {
|
||||
|
||||
// FIXME: reuse in `super::int::ConstInt` and `Scalar::Bits`
|
||||
/// The raw bytes of a simple value.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, TyEncodable, TyDecodable, Hash)]
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(HashStable)]
|
||||
pub struct ScalarInt {
|
||||
/// The first `size` bytes of `data` are the value.
|
||||
@ -127,6 +128,19 @@ pub struct ScalarInt {
|
||||
size: u8,
|
||||
}
|
||||
|
||||
impl<S: Encoder> Encodable<S> for ScalarInt {
|
||||
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
s.emit_u128(self.data())?;
|
||||
s.emit_u8(self.size)
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: Decoder> Decodable<D> for ScalarInt {
|
||||
fn decode(d: &mut D) -> Result<ScalarInt, D::Error> {
|
||||
Ok(ScalarInt { bytes: d.read_u128()?.to_ne_bytes(), size: d.read_u8()? })
|
||||
}
|
||||
}
|
||||
|
||||
impl ScalarInt {
|
||||
pub const TRUE: ScalarInt = ScalarInt { bytes: 1_u128.to_ne_bytes(), size: 1 };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user