Skip to content

Commit 1c27224

Browse files
committed
Switch from bit packing to bools
1 parent 5730903 commit 1c27224

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ pub mod stmt;
8989
pub mod transaction;
9090
pub mod types;
9191

92-
const TYPEINFO_QUERY_BIT: u8 = 0b0000_0001;
93-
const TYPEINFO_ENUM_QUERY_BIT: u8 = 0b0000_0010;
94-
const TYPEINFO_COMPOSITE_QUERY_BIT: u8 = 0b0000_0100;
95-
9692
const TYPEINFO_QUERY: &'static str = "__typeinfo";
9793
const TYPEINFO_ENUM_QUERY: &'static str = "__typeinfo_enum";
9894
const TYPEINFO_COMPOSITE_QUERY: &'static str = "__typeinfo_composite";
@@ -219,7 +215,9 @@ struct InnerConnection {
219215
trans_depth: u32,
220216
desynchronized: bool,
221217
finished: bool,
222-
typeinfo_state: u8,
218+
has_typeinfo_query: bool,
219+
has_typeinfo_enum_query: bool,
220+
has_typeinfo_composite_query: bool,
223221
}
224222

225223
impl Drop for InnerConnection {
@@ -261,7 +259,9 @@ impl InnerConnection {
261259
desynchronized: false,
262260
finished: false,
263261
trans_depth: 0,
264-
typeinfo_state: 0,
262+
has_typeinfo_query: false,
263+
has_typeinfo_enum_query: false,
264+
has_typeinfo_composite_query: false,
265265
};
266266

267267
options.push(("client_encoding".to_owned(), "UTF8".to_owned()));
@@ -628,7 +628,7 @@ impl InnerConnection {
628628
}
629629

630630
fn setup_typeinfo_query(&mut self) -> Result<()> {
631-
if self.typeinfo_state & TYPEINFO_QUERY_BIT != 0 {
631+
if self.has_typeinfo_query {
632632
return Ok(());
633633
}
634634

@@ -655,7 +655,7 @@ impl InnerConnection {
655655
Err(e) => return Err(e),
656656
}
657657

658-
self.typeinfo_state |= TYPEINFO_QUERY_BIT;
658+
self.has_typeinfo_query = true;
659659
Ok(())
660660
}
661661

@@ -705,7 +705,7 @@ impl InnerConnection {
705705
}
706706

707707
fn setup_typeinfo_enum_query(&mut self) -> Result<()> {
708-
if self.typeinfo_state & TYPEINFO_ENUM_QUERY_BIT != 0 {
708+
if self.has_typeinfo_enum_query {
709709
return Ok(());
710710
}
711711

@@ -726,7 +726,7 @@ impl InnerConnection {
726726
Err(e) => return Err(e),
727727
}
728728

729-
self.typeinfo_state |= TYPEINFO_ENUM_QUERY_BIT;
729+
self.has_typeinfo_enum_query = true;
730730
Ok(())
731731
}
732732

@@ -748,7 +748,7 @@ impl InnerConnection {
748748
}
749749

750750
fn setup_typeinfo_composite_query(&mut self) -> Result<()> {
751-
if self.typeinfo_state & TYPEINFO_COMPOSITE_QUERY_BIT != 0 {
751+
if self.has_typeinfo_composite_query {
752752
return Ok(());
753753
}
754754

@@ -760,7 +760,7 @@ impl InnerConnection {
760760
AND attnum > 0 \
761761
ORDER BY attnum"));
762762

763-
self.typeinfo_state |= TYPEINFO_COMPOSITE_QUERY_BIT;
763+
self.has_typeinfo_composite_query = true;
764764
Ok(())
765765
}
766766

0 commit comments

Comments
 (0)