Skip to content

Commit c62763c

Browse files
krallinfacebook-github-bot
authored andcommitted
buck2: switch to compact_str instead of smartstring
Summary: Upsides: - It seems more actively maintained. - Note: on Github issues, they have a couple open reports of fuzz failures (from their automation) but those are from a branch, not master. - It doesn't have this frustrating bug: bodil/smartstring#7 Downsides: - It doesn't convert String to an inlined value in `From`, but we don't actually rely on this (we use small strings mostly when working with directories where those elements are produced via an iterator of FileName). Reviewed By: ndmitchell Differential Revision: D42313656 fbshipit-source-id: 0708866fced3b32941047755b770244287f6ad94
1 parent 56367db commit c62763c

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

allocative/allocative/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ hashbrown = { version = "0.12.3", optional = true }
2222
indexmap = { version = "1.9.1", optional = true }
2323
num-bigint = { version = "0.4.3", optional = true }
2424
parking_lot = { version = "0.11.2", optional = true }
25-
smartstring = { version = "0.2.10", optional = true }
25+
compact_str = { version = "0.6.1", optional = true }
2626
once_cell = { version = "1.16.0", optional = true }
2727
owning_ref = { version = "0.4.1", optional = true }
2828
prost-types = { version = "0.11.2", optional = true }

allocative/allocative/src/impls/smartstring.rs renamed to allocative/allocative/src/impls/compact_str.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@
77
* of this source tree.
88
*/
99

10-
#![cfg(feature = "smartstring")]
10+
#![cfg(feature = "compact_str")]
1111

12-
use smartstring::SmartString;
13-
use smartstring::SmartStringMode;
12+
use compact_str::CompactString;
1413

1514
use crate::allocative_trait::Allocative;
1615
use crate::impls::common::PTR_NAME;
1716
use crate::impls::common::UNUSED_CAPACITY_NAME;
1817
use crate::key::Key;
1918
use crate::visitor::Visitor;
2019

21-
impl<M: SmartStringMode + 'static> Allocative for SmartString<M> {
20+
impl Allocative for CompactString {
2221
fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) {
2322
let mut visitor = visitor.enter_self_sized::<Self>();
24-
if !self.is_inline() {
23+
if self.is_heap_allocated() {
2524
let mut visitor = visitor.enter_unique(PTR_NAME, std::mem::size_of::<*const u8>());
2625
visitor.visit_simple(Key::new("str"), self.len());
2726
let unused_capacity = self.capacity() - self.len();

allocative/allocative/src/impls/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
mod anyhow;
1313
mod bumpalo;
1414
pub(crate) mod common;
15+
mod compact_str;
1516
mod dashmap;
1617
mod either;
1718
mod futures;
@@ -27,6 +28,5 @@ mod prost_types;
2728
mod relative_path;
2829
mod sequence_trie;
2930
mod smallvec;
30-
mod smartstring;
3131
mod sorted_vector_map;
3232
mod std;

0 commit comments

Comments
 (0)