Skip to content

Commit d28c785

Browse files
committed
Add inlining.
1 parent 4ba4212 commit d28c785

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/src/hash/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,12 @@ mod impls {
548548
($(($ty:ident, $meth:ident),)*) => {$(
549549
#[stable(feature = "rust1", since = "1.0.0")]
550550
impl Hash for $ty {
551+
#[inline]
551552
fn hash<H: Hasher>(&self, state: &mut H) {
552553
state.$meth(*self)
553554
}
554555

556+
#[inline]
555557
fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) {
556558
let newlen = data.len() * mem::size_of::<$ty>();
557559
let ptr = data.as_ptr() as *const u8;
@@ -582,20 +584,23 @@ mod impls {
582584

583585
#[stable(feature = "rust1", since = "1.0.0")]
584586
impl Hash for bool {
587+
#[inline]
585588
fn hash<H: Hasher>(&self, state: &mut H) {
586589
state.write_u8(*self as u8)
587590
}
588591
}
589592

590593
#[stable(feature = "rust1", since = "1.0.0")]
591594
impl Hash for char {
595+
#[inline]
592596
fn hash<H: Hasher>(&self, state: &mut H) {
593597
state.write_u32(*self as u32)
594598
}
595599
}
596600

597601
#[stable(feature = "rust1", since = "1.0.0")]
598602
impl Hash for str {
603+
#[inline]
599604
fn hash<H: Hasher>(&self, state: &mut H) {
600605
state.write(self.as_bytes());
601606
state.write_u8(0xff)
@@ -604,6 +609,7 @@ mod impls {
604609

605610
#[stable(feature = "never_hash", since = "1.29.0")]
606611
impl Hash for ! {
612+
#[inline]
607613
fn hash<H: Hasher>(&self, _: &mut H) {
608614
*self
609615
}
@@ -613,6 +619,7 @@ mod impls {
613619
() => (
614620
#[stable(feature = "rust1", since = "1.0.0")]
615621
impl Hash for () {
622+
#[inline]
616623
fn hash<H: Hasher>(&self, _state: &mut H) {}
617624
}
618625
);
@@ -621,6 +628,7 @@ mod impls {
621628
#[stable(feature = "rust1", since = "1.0.0")]
622629
impl<$($name: Hash),+> Hash for ($($name,)+) where last_type!($($name,)+): ?Sized {
623630
#[allow(non_snake_case)]
631+
#[inline]
624632
fn hash<S: Hasher>(&self, state: &mut S) {
625633
let ($(ref $name,)+) = *self;
626634
$($name.hash(state);)+
@@ -650,6 +658,7 @@ mod impls {
650658

651659
#[stable(feature = "rust1", since = "1.0.0")]
652660
impl<T: Hash> Hash for [T] {
661+
#[inline]
653662
fn hash<H: Hasher>(&self, state: &mut H) {
654663
self.len().hash(state);
655664
Hash::hash_slice(self, state)
@@ -658,20 +667,23 @@ mod impls {
658667

659668
#[stable(feature = "rust1", since = "1.0.0")]
660669
impl<T: ?Sized + Hash> Hash for &T {
670+
#[inline]
661671
fn hash<H: Hasher>(&self, state: &mut H) {
662672
(**self).hash(state);
663673
}
664674
}
665675

666676
#[stable(feature = "rust1", since = "1.0.0")]
667677
impl<T: ?Sized + Hash> Hash for &mut T {
678+
#[inline]
668679
fn hash<H: Hasher>(&self, state: &mut H) {
669680
(**self).hash(state);
670681
}
671682
}
672683

673684
#[stable(feature = "rust1", since = "1.0.0")]
674685
impl<T: ?Sized> Hash for *const T {
686+
#[inline]
675687
fn hash<H: Hasher>(&self, state: &mut H) {
676688
#[cfg(not(bootstrap))]
677689
{
@@ -701,6 +713,7 @@ mod impls {
701713

702714
#[stable(feature = "rust1", since = "1.0.0")]
703715
impl<T: ?Sized> Hash for *mut T {
716+
#[inline]
704717
fn hash<H: Hasher>(&self, state: &mut H) {
705718
#[cfg(not(bootstrap))]
706719
{

0 commit comments

Comments
 (0)