inline analysis and symbol reduction; emits smaller than 64 bytes marked inline

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-07-03 20:06:43 +00:00
parent 1e8b8cce0f
commit eeda96d94a
35 changed files with 117 additions and 73 deletions

View file

@ -9,6 +9,7 @@ pub struct Cork {
}
impl Cork {
#[inline]
pub(super) fn new(db: &Arc<Engine>, flush: bool, sync: bool) -> Self {
db.cork();
Self {

View file

@ -19,12 +19,15 @@ impl Database {
})
}
#[inline]
#[must_use]
pub fn cork(&self) -> Cork { Cork::new(&self.db, false, false) }
#[inline]
#[must_use]
pub fn cork_and_flush(&self) -> Cork { Cork::new(&self.db, true, false) }
#[inline]
#[must_use]
pub fn cork_and_sync(&self) -> Cork { Cork::new(&self.db, true, true) }
}

View file

@ -121,6 +121,7 @@ impl Engine {
pub fn sync(&self) -> Result<()> { result(DBCommon::flush_wal(&self.db, true)) }
#[inline]
pub fn corked(&self) -> bool { self.corks.load(std::sync::atomic::Ordering::Relaxed) > 0 }
pub(crate) fn cork(&self) {
@ -242,6 +243,7 @@ impl Engine {
}
impl Drop for Engine {
#[cold]
fn drop(&mut self) {
const BLOCKING: bool = true;

View file

@ -17,9 +17,11 @@ impl<'a> From<DBPinnableSlice<'a>> for Handle<'a> {
impl Deref for Handle<'_> {
type Target = [u8];
#[inline]
fn deref(&self) -> &Self::Target { &self.val }
}
impl AsRef<[u8]> for Handle<'_> {
#[inline]
fn as_ref(&self) -> &[u8] { &self.val }
}

View file

@ -199,6 +199,7 @@ impl<'a> IntoIterator for &'a Map {
type IntoIter = Box<dyn Iterator<Item = Self::Item> + Send + 'a>;
type Item = OwnedKeyValPair;
#[inline]
fn into_iter(self) -> Self::IntoIter { self.iter() }
}

View file

@ -11,21 +11,19 @@ pub type Key = [Byte];
pub(crate) type Byte = u8;
impl OwnedKeyVal {
#[inline]
#[must_use]
pub fn as_slice(&self) -> KeyVal<'_> { KeyVal(&self.0, &self.1) }
#[inline]
#[must_use]
pub fn to_tuple(self) -> OwnedKeyValPair { (self.0, self.1) }
}
impl From<OwnedKeyValPair> for OwnedKeyVal {
#[inline]
fn from((key, val): OwnedKeyValPair) -> Self { Self(key, val) }
}
impl From<&KeyVal<'_>> for OwnedKeyVal {
#[inline]
fn from(slice: &KeyVal<'_>) -> Self { slice.to_owned() }
}
@ -34,7 +32,6 @@ impl From<KeyValPair<'_>> for OwnedKeyVal {
}
impl From<OwnedKeyVal> for OwnedKeyValPair {
#[inline]
fn from(val: OwnedKeyVal) -> Self { val.to_tuple() }
}
@ -43,22 +40,18 @@ impl KeyVal<'_> {
#[must_use]
pub fn to_owned(&self) -> OwnedKeyVal { OwnedKeyVal::from(self) }
#[inline]
#[must_use]
pub fn as_tuple(&self) -> KeyValPair<'_> { (self.0, self.1) }
}
impl<'a> From<&'a OwnedKeyVal> for KeyVal<'a> {
#[inline]
fn from(owned: &'a OwnedKeyVal) -> Self { owned.as_slice() }
}
impl<'a> From<&'a OwnedKeyValPair> for KeyVal<'a> {
#[inline]
fn from((key, val): &'a OwnedKeyValPair) -> Self { KeyVal(key.as_slice(), val.as_slice()) }
}
impl<'a> From<KeyValPair<'a>> for KeyVal<'a> {
#[inline]
fn from((key, val): KeyValPair<'a>) -> Self { KeyVal(key, val) }
}