Skip to content

Commit 4bebfcb

Browse files
committed
fix
1 parent e5ddb57 commit 4bebfcb

File tree

2 files changed

+2
-89
lines changed

2 files changed

+2
-89
lines changed

src/functions/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,8 @@ impl RawJsonb<'_> {
11051105
/// ```
11061106
pub fn extract_scalar_key_values(&self) -> Result<Vec<(KeyPaths<'_>, Value<'_>)>> {
11071107
let item = JsonbItem::from_raw_jsonb(*self)?;
1108-
let mut result = Vec::new();
1109-
let mut current_paths = Vec::new();
1108+
let mut result = Vec::with_capacity(16);
1109+
let mut current_paths = Vec::with_capacity(3);
11101110
Self::extract_scalar_key_values_recursive(item, &mut current_paths, &mut result)?;
11111111
Ok(result)
11121112
}

src/keypath.rs

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313
// limitations under the License.
1414

1515
use std::borrow::Cow;
16-
use std::cmp::Ordering;
1716
use std::fmt::Display;
1817
use std::fmt::Formatter;
19-
use std::hash::Hash;
20-
use std::hash::Hasher;
2118

2219
use nom::branch::alt;
2320
use nom::character::complete::char;
@@ -53,90 +50,6 @@ pub enum KeyPath<'a> {
5350
Name(Cow<'a, str>),
5451
}
5552

56-
impl Eq for KeyPaths<'_> {}
57-
58-
impl PartialEq for KeyPaths<'_> {
59-
fn eq(&self, other: &Self) -> bool {
60-
let result = self.cmp(other);
61-
result == Ordering::Equal
62-
}
63-
}
64-
65-
impl PartialOrd for KeyPaths<'_> {
66-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
67-
Some(self.cmp(other))
68-
}
69-
}
70-
71-
impl Ord for KeyPaths<'_> {
72-
fn cmp(&self, other: &Self) -> Ordering {
73-
for (self_path, other_path) in self.paths.iter().zip(other.paths.iter()) {
74-
let ord = self_path.cmp(other_path);
75-
if ord != Ordering::Equal {
76-
return ord;
77-
}
78-
}
79-
self.paths.len().cmp(&other.paths.len())
80-
}
81-
}
82-
83-
impl Eq for KeyPath<'_> {}
84-
85-
impl PartialEq for KeyPath<'_> {
86-
fn eq(&self, other: &Self) -> bool {
87-
let ord = self.cmp(other);
88-
ord == Ordering::Equal
89-
}
90-
}
91-
92-
impl PartialOrd for KeyPath<'_> {
93-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
94-
Some(self.cmp(other))
95-
}
96-
}
97-
98-
impl Ord for KeyPath<'_> {
99-
fn cmp(&self, other: &Self) -> Ordering {
100-
match (self, other) {
101-
(KeyPath::Index(v1), KeyPath::Index(v2)) => v1.cmp(v2),
102-
(
103-
KeyPath::QuotedName(v1) | KeyPath::Name(v1),
104-
KeyPath::QuotedName(v2) | KeyPath::Name(v2),
105-
) => v1.cmp(v2),
106-
(KeyPath::QuotedName(_) | KeyPath::Name(_), KeyPath::Index(_)) => Ordering::Greater,
107-
(KeyPath::Index(_), KeyPath::QuotedName(_) | KeyPath::Name(_)) => Ordering::Less,
108-
}
109-
}
110-
}
111-
112-
impl Hash for KeyPath<'_> {
113-
fn hash<H: Hasher>(&self, state: &mut H) {
114-
match self {
115-
KeyPath::Index(idx) => {
116-
// Hash a discriminant to distinguish from other variants
117-
0_u8.hash(state);
118-
idx.hash(state);
119-
}
120-
KeyPath::QuotedName(name) => {
121-
// Hash a discriminant to distinguish from other variants
122-
1_u8.hash(state);
123-
name.hash(state);
124-
}
125-
KeyPath::Name(name) => {
126-
// Hash a discriminant to distinguish from other variants
127-
2_u8.hash(state);
128-
name.hash(state);
129-
}
130-
}
131-
}
132-
}
133-
134-
impl Hash for KeyPaths<'_> {
135-
fn hash<H: Hasher>(&self, state: &mut H) {
136-
self.paths.hash(state);
137-
}
138-
}
139-
14053
impl Display for KeyPaths<'_> {
14154
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
14255
write!(f, "{{")?;

0 commit comments

Comments
 (0)