commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
f1e06491235c5f7c8b9c095064d69553a282b78c | René Kijewski | 2023-10-27T02:10:25 | Inline short static strings (#321)
This way short static strings have better cache locality, too. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index d8f923fd..683a6677 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -212,6 +212,9 @@ impl CompactString {
/// Creates a new inline [`CompactString`] at compile time.
///
+ /// For most use cases you should use the metho... | 3 | 21 | 11 |
3179b0394d51ec7d0aae83943ee6c4ab603853ed | René Kijewski | 2023-10-27T01:50:29 | Simplify `is_empty()` (#330)
* Simplify `is_empty()`
Before:
```asm
0000000000000000 <<compact_str::CompactString>::is_empty>:
0: 48 8b 77 08 mov 0x8(%rdi),%rsi
4: 0f b6 57 17 movzbl 0x17(%rdi),%edx
8: 48 8d 8a 40 ff ff ff lea -0xc0(%rdx),%rcx
f: 48 83 f9... | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 0750029c..d8f923fd 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -499,7 +499,7 @@ impl CompactString {
/// ```
#[inline]
pub fn is_empty(&self) -> bool {
- self.len() == 0
+ self.0.is_empty()
}
... | 3 | 66 | 23 |
ec68bf0bc523cd31e217ab085991aa33cf5d1f7f | Jiahao XU | 2023-10-23T15:57:56 | Impl `Clone::clone_from` for `CompactString` (#325)
As an optimization for certain usecase where you already have a
`CompactString` and want to reuse the heap allocation.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 54ddce0b..0750029c 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -150,7 +150,6 @@ mod tests;
/// A consequence of eagerly inlining is you then need to de-allocate the existing buffer, which
/// might not always be desirable if yo... | 2 | 47 | 1 |
3814400dcd83af8814538a176b45ad87e02d1542 | Parker Timmerman | 2023-10-08T20:31:01 | update (#320) | diff --git a/examples/bytes/Cargo.toml b/examples/bytes/Cargo.toml
index 439c12c4..34d17166 100644
--- a/examples/bytes/Cargo.toml
+++ b/examples/bytes/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2021"
[dependencies]
bytes = "1"
-compact_str = { version = "0.7", features = ["bytes"] }
+compact_str = { version = "0.8.0-be... | 4 | 4 | 4 |
7d6bee1da91336b5ed9f1de199066eb15a0d8da8 | Parker Timmerman | 2023-10-08T19:36:32 | bump version to v0.8.0-beta (#312) | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 4bfae67f..3a5733b4 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "compact_str"
description = "A memory efficient string type that transparently stores strings on the stack, when possible"
-version =... | 1 | 1 | 1 |
be2a9a46aa9f861be6708d16710627e1d0796c14 | Parker Timmerman | 2023-10-08T14:28:26 | start, add FromStaticStr to the creation steps (#314) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index e4cd1ea2..fe74f13f 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1054,7 +1054,8 @@ impl CompactString {
/// Split the [`CompactString`] into at the given byte index.
///
- /// Calling this function does not change t... | 5 | 52 | 6 |
edb8f649189d74a44d8c68b9c360c5b4265ed825 | Parker Timmerman | 2023-10-08T01:08:18 | start' (#309) | diff --git a/compact_str/src/repr/capacity.rs b/compact_str/src/repr/capacity.rs
index bab7b416..778309a1 100644
--- a/compact_str/src/repr/capacity.rs
+++ b/compact_str/src/repr/capacity.rs
@@ -145,20 +145,17 @@ mod tests {
assert_eq!(16777215, after);
}
- #[rustversion::since(1.63)]
#[test]
... | 1 | 2 | 5 |
796ac25c8e6ebdc5af2c48acd2f4a0cdfddcb5eb | Parker Timmerman | 2023-10-08T00:19:01 | start, add test coverage for repeat (#277) | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index 7a5b45f1..3c47e43b 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -1632,6 +1632,15 @@ fn proptest_from_utf16(#[strategy(rand_u16s())] buf: Vec<u16>) {
}
}
+#[proptest]
+#[cfg_attr(miri, ignore)]
+fn proptest_repeat(n... | 4 | 32 | 3 |
ee5a6c11caa7bf6d503968901640122c704dc8d3 | René Kijewski | 2023-10-07T20:51:30 | Remove branches from `Repr::as_slice()` (#306)
* Remove branches from `Repr::as_slice()`
This change optimizes `Repr::as_slice()`, which is used e.g. in
`CompactStr::as_str()`.
This is done by replacing
`last_byte == HEAP_MASK || last_byte == STATIC_STR_MASK` with
`last_byte >= HEAP_MASK`, because we know tha... | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index 4a666aaf..7c4d5ded 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -358,23 +358,20 @@ impl Repr {
/// Returns the string content, and only the string content, as a slice of bytes.
#[inline]
pub fn a... | 1 | 9 | 12 |
9f466f0b58fa9b67c0682910bd958e9ccf5b2d49 | Parker Timmerman | 2023-10-07T20:48:58 | use core::ptr::read instead of std::ptr::read | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index 1bf37250..4a666aaf 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -675,7 +675,7 @@ impl Clone for Repr {
} else {
// SAFETY: We just checked that `self` can be copied because it is an inline... | 1 | 1 | 1 |
c7d7d11c0450ceebe0c658d8e954fc1c0e32c0b4 | René Kijewski | 2023-10-07T19:58:30 | Simplify `clone()` (#299) | diff --git a/compact_str/src/repr/inline.rs b/compact_str/src/repr/inline.rs
index 8b7ba612..952e3584 100644
--- a/compact_str/src/repr/inline.rs
+++ b/compact_str/src/repr/inline.rs
@@ -113,11 +113,6 @@ impl InlineBuffer {
self.0[MAX_SIZE - 1] = len as u8 | LENGTH_MASK;
}
}
-
- #[inline(a... | 2 | 10 | 41 |
64b940df2073433ca619a0381d0f2630988b36cd | Parker Timmerman | 2023-10-07T17:29:01 | fix: Remove String specialization (#305)
* start, remove string specialization
* cargo fmt
* use core::asm instead of std::asm | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index 88865ee5..f9638b0a 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -403,7 +403,7 @@ impl Repr {
// SAFETY: This assembly instruction is a noop that only affects the instruction ordering.
#[cfg(no... | 2 | 9 | 3 |
10acf0249d8cd2c6b93836c5a1f28f82c3def9a5 | René Kijewski | 2023-08-30T13:36:27 | Fix and optimize `Capacity` (#285)
* Fix `Capacity` mask
In <https://github.com/ParkMyCar/compact_str/pull/276> I changed the
value of the byte that tells if a string is stored on the heap, but I
forgot to update the test for `Capacity`.
* Capacity: inline const fn call
* Capacity: remove outdated comment
... | diff --git a/compact_str/src/repr/capacity.rs b/compact_str/src/repr/capacity.rs
index 2bff6ebb..ff3d10df 100644
--- a/compact_str/src/repr/capacity.rs
+++ b/compact_str/src/repr/capacity.rs
@@ -1,31 +1,36 @@
-use crate::repr::HEAP_MASK;
+use core::fmt;
+
+use crate::repr::LastUtf8Char;
// how many bytes a `usize` o... | 1 | 43 | 44 |
4ca0f9eb3fb88d36593fa28b964f4b8698027603 | Jiahao XU | 2023-08-30T13:35:14 | feat: Impl `CompactString::from_str_to_{lower, upper}case` (#284)
Enable converting a `str` to lower/upper case and get a `CompactString`
directly for inline storage.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index c9707d35..170d74a6 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1647,14 +1647,58 @@ impl CompactString {
///
/// assert_eq!(new_year, new_year.to_lowercase());
/// ```
- #[must_use = "this returns the lowercase ... | 1 | 90 | 6 |
085c46982a6a2c57096388c99c67a94217ea9c3e | René Kijewski | 2023-08-30T13:29:36 | Simplify `Repr::len()` (#283)
Using the fact that `LastUtf8Char::Heap` comes exactly after the last
inline length value, we can simplify the calculation a bit.
The resulting code on amd64:
```asm
mov 0x8(%rdi),%rax
movzbl 0x17(%rdi),%ecx
add $0xffffffffffffff40,%rcx
cmp $0x18,%rcx
cmovae %rax,%rcx... | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index e65b412e..d1928fd4 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -381,23 +381,36 @@ impl Repr {
#[allow(clippy::len_without_is_empty)] // is_empty exists on CompactString
#[inline]
pub fn len(&sel... | 1 | 27 | 14 |
3f576628dde12a29f994f5ba5a10c6d6cdf06de9 | Jiahao XU | 2023-07-25T12:53:33 | feat: Implement case conversion fn for `CompactString` (#274)
- `CompactString::to_ascii_lowercase`
- `CompactString::to_ascii_uppercase`
- `CompactString::to_lowercase`
- `CompactString::to_uppercase`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 9b20cfbc..c9707d35 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -27,6 +27,7 @@ use core::str::{
};
use core::{
fmt,
+ mem,
slice,
};
use std::borrow::Cow;
@@ -35,6 +36,7 @@ use std::iter::FusedIterator;
mod fea... | 3 | 432 | 0 |
913ad3aa5fbc14bbb2df9915c4caa89ae2ea5779 | René Kijewski | 2023-07-18T13:19:44 | Clippy: replace `.rev().next()` by `.next_back()` (#278) | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index 52ec5310..ca5266fa 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -335,7 +335,7 @@ impl Repr {
#[inline]
pub fn pop(&mut self) -> Option<char> {
- let ch = self.as_str().chars().rev().next()?;
... | 1 | 1 | 1 |
65e4620d9048790f4bddeaa4ea8d4e5af3cdee41 | Jiahao XU | 2023-07-18T03:22:21 | feat: Implement `CompactString::repeat` (#275)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 7b9952ac..9b20cfbc 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -844,6 +844,42 @@ impl CompactString {
core::ptr::copy_nonoverlapping(replace_with.as_ptr(), data.add(start), replace_with.len());
}
+ /// Creates ... | 1 | 36 | 0 |
98106fb1637c7afb2f0245b960649b3c3c696448 | Parker Timmerman | 2023-06-08T03:22:01 | bump build number (#271) | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 895fb93b..751244b8 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "compact_str"
description = "A memory efficient string type that transparently stores strings on the stack, when possible"
-version =... | 1 | 1 | 1 |
9e00e7d6fcfd36a6f2608f3b09211128af10d64c | Parker Timmerman | 2023-02-23T04:33:21 | branch start, update examples to v0.7 (#267) | diff --git a/examples/bytes/Cargo.toml b/examples/bytes/Cargo.toml
index 27e6312d..439c12c4 100644
--- a/examples/bytes/Cargo.toml
+++ b/examples/bytes/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2021"
[dependencies]
bytes = "1"
-compact_str = { version = "0.6", features = ["bytes"] }
+compact_str = { version = "0.7", fe... | 4 | 4 | 4 |
f528b1a323293b28e6741a4791ee3af2a12fa582 | Parker Timmerman | 2023-02-20T19:46:42 | branch start, add new fuzzing action to test into_bytes (#263) | diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index 1c4b41cb..47128690 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -11,7 +11,7 @@ cargo-fuzz = true
[dependencies]
arbitrary = { version = "1.1.1", features = ["derive"] }
bytes = "1"
-compact_str = { path = "../compact_str", features = ["bytes"] }
+compact_... | 2 | 30 | 1 |
a0102912a21dfc27a738bacdc24266dcaed97b6c | Parker Timmerman | 2023-02-20T19:34:14 | refactor: Reduce or wrap unsafe code (#260)
* branch start, wrap our reinterprets in safe methods, or unsafe methods with doc comments
* gate into_inline under the smallvec feature | diff --git a/compact_str/src/repr/iter.rs b/compact_str/src/repr/iter.rs
index e25efd3c..38ca6bcd 100644
--- a/compact_str/src/repr/iter.rs
+++ b/compact_str/src/repr/iter.rs
@@ -49,8 +49,10 @@ impl FromIterator<char> for Repr {
curr_len += char_len;
}
+ // SAFETY: Everything we just push... | 3 | 164 | 48 |
1bb4ae9cb902240e3eec50d5095ff22d4b9a189d | Parker Timmerman | 2023-02-19T22:40:03 | branch start, bump version to v0.7 (#259) | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 42450e0d..d6c9301a 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "compact_str"
description = "A memory efficient string type that transparently stores strings on the stack, when possible"
-version =... | 1 | 1 | 1 |
4430ab9e506c041be4ebcc9e0cb5e24088a873df | Parker Timmerman | 2023-02-18T15:17:08 | api: Add CompactString::into_bytes (#258) | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index b26c8fdb..42450e0d 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -19,6 +19,7 @@ proptest = { version = "1", optional = true, default-features = false, features
quickcheck = { version = "1", optional = true, default-features = fals... | 6 | 214 | 0 |
540836459a2f5dfe131aebd5ad9642a906c11737 | Parker Timmerman | 2023-02-18T00:04:20 | branch start, when cloning eagerly inline based on length, not capacity (#257) | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index ea962ed4..aef1873a 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -501,9 +501,8 @@ impl Clone for Repr {
let heap = unsafe { &*(this as *const _ as *const HeapBuffer) };
// If the cont... | 2 | 3 | 4 |
146479e787111ab80ff6219433a3ffb1b0204173 | Parker Timmerman | 2023-02-18T00:04:06 | api: Update From<String> and From<Box<str>> to eagerly inline (#256)
* branch start, make From<String> and From<Box<str>> eagerly inline, add from_string_buffer API
* update unit tests
* several changes
- add doc comment to CompactString explaining the behavior of From<String>
- change Repr::from_string to eag... | diff --git a/compact_str/src/features/proptest.rs b/compact_str/src/features/proptest.rs
index e0b5bcf5..d756fd61 100644
--- a/compact_str/src/features/proptest.rs
+++ b/compact_str/src/features/proptest.rs
@@ -29,6 +29,8 @@ mod test {
use crate::CompactString;
+ const MAX_SIZE: usize = std::mem::size_of::<... | 6 | 295 | 134 |
3e72e09d801aa1db2f9df9ea21be9fd47657e8fb | Parker Timmerman | 2023-02-17T19:18:23 | branch start, use castaway 0.2 instead of 0.2.1 so we can get improved patch versions (#252) | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index bc417452..b26c8fdb 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -20,7 +20,7 @@ quickcheck = { version = "1", optional = true, default-features = false }
rkyv = { version = "0.7", optional = true }
serde = { version = "1", option... | 1 | 1 | 1 |
fb93a8475c74e59963f3a615e388040b33885e9d | Parker Timmerman | 2023-02-16T02:21:09 | perf: Inline strings when Clone-ing (#254)
* branch start, inline string on clone if the capacity is small enough
* update fuzzing harness to make sure we're inlining strings | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index 8e168c5a..84fc7428 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -534,8 +534,19 @@ impl Clone for Repr {
#[cold]
fn clone_heap(this: &Repr) -> Repr {
let heap = unsafe { &*(this as... | 3 | 38 | 2 |
44e6e07246391fdd736ccf441e5418a9674e4e7e | Parker Timmerman | 2023-02-13T20:58:16 | branch start, pick a random number to be the 'max' number of actions run when fuzzing (#255) | diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index fea07b50..1c4b41cb 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -12,6 +12,8 @@ cargo-fuzz = true
arbitrary = { version = "1.1.1", features = ["derive"] }
bytes = "1"
compact_str = { path = "../compact_str", features = ["bytes"] }
+rand = { version = "0.8"... | 3 | 110 | 1 |
932f486737c3d82b4c4ecc3225e11c44de22755c | Parker Timmerman | 2023-02-12T21:41:33 | branch start, add test (#253) | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index 4d5f47ab..bda16e04 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -1449,3 +1449,12 @@ fn test_collect() {
"foobarbaz",
);
}
+
+#[test]
+fn test_into_cow() {
+ let og = "aaa";
+ let compact = CompactStrin... | 1 | 9 | 0 |
427844cc443e82696f9ae040c07ee2c6b8eb91a6 | Vikram Bhaskaran | 2023-01-17T14:36:52 | Fix a typo in documentation (#235) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 8b4d4e41..95405f72 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -78,7 +78,7 @@ mod tests;
/// }
///
/// // CompactString impls AsRef<str> and Borrow<str>, so it can be used anywhere
-/// // that excepts a generic string
+/// //... | 1 | 1 | 1 |
a510515ca8210efdc14bd65bab92861041c8e20d | René Kijewski | 2023-01-16T16:55:13 | Implement `From<CompactString> for Cow<'_, str>` (#228) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 6be14b0d..e8bd7aeb 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1532,6 +1532,20 @@ impl From<CompactString> for String {
}
}
+impl From<CompactString> for Cow<'_, str> {
+ #[inline]
+ fn from(s: CompactString) -> Se... | 1 | 14 | 0 |
30ac822234c280a3b56e8f72d922150315e651a1 | Mike Cronce | 2023-01-02T02:40:44 | compact_str/src/lib.rs: impl AsRef<[u8]> (#230) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index b9b449c8..6be14b0d 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1425,6 +1425,13 @@ impl AsRef<OsStr> for CompactString {
}
}
+impl AsRef<[u8]> for CompactString {
+ #[inline]
+ fn as_ref(&self) -> &[u8] {
+ s... | 1 | 7 | 0 |
f592066c99e9e9b8ae577edcc48634ac266b2baa | René Kijewski | 2022-08-28T00:27:59 | Copy inline string reversed (#219)
It seem like some optimization step goes berserk if you copy a byte
slice from start to end. The while-loop is partially unrolled which
results in an excessively long, extremely cache unfriendly code.
If you copy the string in the reverse direction, starting with the last
byte,... | diff --git a/compact_str/src/repr/inline.rs b/compact_str/src/repr/inline.rs
index 98e6ecd3..758d114f 100644
--- a/compact_str/src/repr/inline.rs
+++ b/compact_str/src/repr/inline.rs
@@ -41,11 +41,14 @@ impl InlineString {
// set the length
buffer[MAX_SIZE - 1] = len as u8 | LENGTH_MASK;
- //... | 1 | 8 | 5 |
15c4aa35841e7697ff2c2bca645188b09b28df40 | René Kijewski | 2022-08-28T00:26:28 | Implement more `FromIterator` & `Extend` traits (#218) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 20638cc0..17984856 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1372,6 +1372,20 @@ impl CompactString {
pub fn from_utf16be_lossy(v: impl AsRef<[u8]>) -> Self {
CompactString::from_utf16x_lossy(v.as_ref(), u16::from... | 3 | 140 | 1 |
b2d72237c52b4c56cb99b80c38a404eb8daf0a7b | Parker Timmerman | 2022-08-22T14:13:00 | bump version to v0.6.1 | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 4005d88a..96c34f65 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "compact_str"
description = "A memory efficient string type that transparently stores strings on the stack, when possible"
-version =... | 1 | 1 | 1 |
e7e14527d30725c833e9f4922436aa5c727516a0 | René Kijewski | 2022-08-22T14:11:22 | Enable "proptest/std" feature (#217)
The last build on docs.rs failed:
<https://docs.rs/crate/compact_str/0.6.0/builds/615366>.
To use proptest, you have to either enable "std" or "alloc". Because
this project uses features in "std", we can enable "proptest/std". We
know that the support is there.
I cannot tell... | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 26506a5a..4005d88a 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -15,7 +15,7 @@ categories = ["encoding", "parsing", "memory-management", "text-processing"]
arbitrary = { version = "1", optional = true, default-features = false }
... | 1 | 1 | 1 |
ef96fbed58af61756df9f2eac8e295c64e0f6b49 | Parker Timmerman | 2022-08-21T23:14:03 | assert suffix data when calling .align_to is empty (#215) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index d37a06d8..20638cc0 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1229,7 +1229,7 @@ impl CompactString {
// SAFETY: `u8` and `u16` are `Copy`, so if the alignment fits, we can transmute a
// `[u8; 2*N]` to... | 1 | 2 | 2 |
493760578c7d0754c64bf11192af58ade30bfca2 | Parker Timmerman | 2022-08-21T23:03:16 | add fuzzing action that clones the strings, and replaces the originals (#214) | diff --git a/fuzz/src/actions.rs b/fuzz/src/actions.rs
index 4d7994b5..4cb3e24f 100644
--- a/fuzz/src/actions.rs
+++ b/fuzz/src/actions.rs
@@ -42,6 +42,8 @@ pub enum Action<'a> {
ShrinkTo(u16, u16),
/// Remove every nth character, and every character over a specific code point
Retain(u8, char),
+ /// ... | 1 | 11 | 0 |
a088dfe1f9e215eec5d85f25bf7658b1ef00fd82 | Parker Timmerman | 2022-08-21T22:25:51 | add more fuzzing creation actions (#212)
* BytesLossy, uses CompactString::from_utf8_lossy
* BytesUtf16BELossy, uses CompactString::from_utf16be_lossy
* BytesUtf16LELossy, uses CompactString::from_utf16le_lossy
* BytesUtf16BE, uses CompactString::from_utf16be
* BytesUtf16LE, uses CompactString::from_utf16le
* Wor... | diff --git a/fuzz/src/actions.rs b/fuzz/src/actions.rs
index 010c6a68..4d7994b5 100644
--- a/fuzz/src/actions.rs
+++ b/fuzz/src/actions.rs
@@ -42,12 +42,6 @@ pub enum Action<'a> {
ShrinkTo(u16, u16),
/// Remove every nth character, and every character over a specific code point
Retain(u8, char),
- ///... | 2 | 143 | 116 |
daee1ebe5e79fa320beaa8c5adee3fa1c881f8d8 | Parker Timmerman | 2022-08-21T21:26:53 | implement from_utf16_lossy (#211)
* add proptests
* add doc tests
* add to fuzzing harness | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 57348665..d37a06d8 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -332,6 +332,36 @@ impl CompactString {
Ok(ret)
}
+ /// Decode a UTF-16–encoded slice `v` into a `CompactString`, replacing invalid data with
+ /... | 3 | 56 | 0 |
2dd09b00aa3583392a9279644980474267687183 | René Kijewski | 2022-08-21T20:33:42 | Implement `from_utf16ne_lossy` and `from_utf16be_lossy` (#210) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index f564ff73..57348665 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1191,10 +1191,10 @@ impl CompactString {
}
// Note: we don't use collect::<Result<_, _>>() because that fails to pre-allocate a buffer,
- ... | 3 | 164 | 2 |
dd4b1036b748f096f083b77ab59f132915a8e0ca | Parker Timmerman | 2022-08-17T15:47:27 | add testing for rkyv and serde feature (#209)
* adds proptest for rkyv
* adds unit test and proptests for serde | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index e904d16b..3b8933ea 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -29,6 +29,8 @@ cfg-if = "1"
proptest = { version = "1", default-features = false, features = ["std"] }
quickcheck_macros = "1"
rayon = "1"
+serde = { version = "1"... | 3 | 137 | 22 |
f6c27029909915595c484890b033f3f0b0f4e081 | Parker Timmerman | 2022-08-16T14:39:16 | bump version number to 0.6.0-alpha.6 | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 69907737..ed123ab9 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "compact_str"
description = "A memory efficient string type that transparently stores strings on the stack, when possible"
-version =... | 1 | 1 | 1 |
b1f7f42f9c4f59075fd5896b1544b365bf66e52b | René Kijewski | 2022-08-16T14:26:26 | Implement `from_utf16le`, `from_utf16be`, `from_utf16ne` (#207) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index f1b62e6a..f564ff73 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -8,7 +8,6 @@ use core::borrow::{
BorrowMut,
};
use core::cmp::Ordering;
-use core::fmt;
use core::hash::{
Hash,
Hasher,
@@ -26,6 +25,10 @@ use core:... | 3 | 218 | 2 |
165497d2ed304deeba30e62ffea180b3333bd43d | Parker Timmerman | 2022-08-13T04:09:59 | fix new Clippy lint introduced in rustc 1.63 | diff --git a/compact_str/src/traits.rs b/compact_str/src/traits.rs
index f691c125..7e51ec79 100644
--- a/compact_str/src/traits.rs
+++ b/compact_str/src/traits.rs
@@ -86,7 +86,7 @@ impl<T: fmt::Display> ToCompactString for T {
&f64 as s => s.into_repr(),
&bool as s => s.into_repr(),
... | 1 | 1 | 1 |
c734b34d913765d5e1099445f729248e93ff0486 | René Kijewski | 2022-08-12T23:32:13 | Implement `from_utf8_lossy()` (#198)
* Implement `from_utf8_lossy()` | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 53f6ebe1..f1b62e6a 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1053,6 +1053,129 @@ impl CompactString {
// SAFETY: We know that the index is a valid position to break the string.
unsafe { self.set_len(dest_idx)... | 3 | 146 | 4 |
61f0ea3fea398e7941d390dbf30683aa0278a5a3 | René Kijewski | 2022-08-12T23:20:37 | Don't format char to determine it's UTF-8 length (#197) | diff --git a/compact_str/src/utility.rs b/compact_str/src/utility.rs
index 98cd0eb5..d4d338c9 100644
--- a/compact_str/src/utility.rs
+++ b/compact_str/src/utility.rs
@@ -19,6 +19,12 @@ impl Write for Sink {
self.0 += s.len();
Ok(())
}
+
+ #[inline(always)]
+ fn write_char(&mut self, c: cha... | 1 | 6 | 0 |
7f1a36c128f4d96fcb45aa397a3abe75530d03a2 | René Kijewski | 2022-08-12T23:19:51 | Macro hygiene: use re-exported `format_args!()` (#196)
So that `format_compact!()` still works if the user shadows
`format_args!()`, or uses the library in a `#![no_implicit_prelude]`
context. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index c25d365e..53f6ebe1 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -1,6 +1,8 @@
#![doc = include_str!("../README.md")]
#![cfg_attr(docsrs, feature(doc_cfg))]
+#[doc(hidden)]
+pub use core;
use core::borrow::{
Borrow,
B... | 3 | 6 | 16 |
0f8b885d31515ef68fa3c455e39174fd33f7b11a | Parker Timmerman | 2022-08-07T13:51:58 | bump version number to 0.6.0-alpha.5 | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index cbf39367..69907737 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "compact_str"
description = "A memory efficient string type that transparently stores strings on the stack, when possible"
-version =... | 1 | 1 | 1 |
2468e9aa00016c4903505ee86469f96bbcfde7b9 | Parker Timmerman | 2022-08-07T03:18:32 | add from_utf8_unchecked API (#194)
* add unit tests
* add proptests
* add fuzzing | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 5ebca697..c25d365e 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -253,6 +253,40 @@ impl CompactString {
Ok(CompactString { repr })
}
+ /// Converts a vector of bytes to a [`CompactString`] without checking that t... | 4 | 189 | 0 |
8bd7fc35bbd0cf2600486dd52b6245dd292039bb | Parker Timmerman | 2022-08-06T17:50:03 | bump version number to 0.6.0-alpha.4 | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 80579b64..cbf39367 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "compact_str"
description = "A memory efficient string type that transparently stores strings on the stack, when possible"
-version =... | 1 | 1 | 1 |
a733675804b67cbbdc5bd5ce861813cd79a0b94c | René Kijewski | 2022-08-06T17:36:43 | Implement `retain()` (#193) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 405352f8..5ebca697 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -975,6 +975,48 @@ impl CompactString {
pub fn shrink_to_fit(&mut self) {
self.repr.shrink_to(0);
}
+
+ /// Retains only the characters specified... | 2 | 67 | 0 |
714bd479fc787f39516c7e7576e2783a33622919 | René Kijewski | 2022-08-06T17:00:16 | Implement `shrink_to()` and `shrink_to_fit()` (#155)
Closes #143, closes #144. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 99e06fc9..405352f8 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -908,6 +908,73 @@ impl CompactString {
chars: self[start..end].chars(),
}
}
+
+ /// Shrinks the capacity of this [`CompactString`] with ... | 5 | 156 | 4 |
e6cadd473bdc5d8b8a50bd0c9f099b469f051d88 | Parker Timmerman | 2022-07-26T21:27:15 | bump version number to 0.6.0-alpha.3 | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 741e1639..80579b64 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "compact_str"
description = "A memory efficient string type that transparently stores strings on the stack, when possible"
-version =... | 1 | 1 | 1 |
cfba5be04ee402929e3cf22473c405f1f1aeecf5 | Parker Timmerman | 2022-07-26T21:15:11 | feat: Implement CompactString::remove() (#191)
* implement remove() API
* add unit tests
* add doc tests
* add prop tests
* add to fuzzing harness
* update helper method in fuzzing harness, add more tests | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 8c2ec7a5..99e06fc9 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -507,6 +507,72 @@ impl CompactString {
self.repr.push_str(s)
}
+ /// Removes a [`char`] from this [`CompactString`] at a byte position and returns ... | 3 | 175 | 1 |
ecf29adb496b322fad26cbee0adea126cb81004b | Parker Timmerman | 2022-07-25T13:55:35 | increment the version number on master to 0.6.0-alpha | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index 4208a597..502d3ec5 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "compact_str"
description = "A memory efficient string type that transparently stores strings on the stack, when possible"
-version =... | 1 | 1 | 1 |
2c4646629b9b7dc822965cfbef3bdba263bc700d | Parker Timmerman | 2022-07-25T02:24:42 | perf: Implement realloc for BoxString (#160)
* implement realloc for BoxString
* implements a realloc method as a performance optimization for BoxString
* cleans up the implementation of BoxString and tries to hint at the likeliness of braches
* use compile_error on platforms that aren't 64 or 32 bits | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index bd6df039..4208a597 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -24,6 +24,7 @@ itoa = "1"
ryu = "1"
[dev-dependencies]
+cfg-if = "1"
proptest = { version = "1", default-features = false, features = ["std"] }
quickcheck_macro... | 4 | 320 | 190 |
d7673f9022156bb32bbc02ad474955fbd043a39a | Parker Timmerman | 2022-07-25T00:36:14 | fix: Test case discovered by AFL (#161)
* fix: Bug when trying to create a CompactString with capacity of 16711422 on 32-bit arches
* Fixed the underlying bug, which was related to the change in HEAP_MASK
* Add debug.rs binary to repro single failing fuzz cases
* Add unit test with comment to repro the exact failur... | diff --git a/compact_str/src/repr/boxed/capacity.rs b/compact_str/src/repr/boxed/capacity.rs
index 1dc00605..1d4f60cd 100644
--- a/compact_str/src/repr/boxed/capacity.rs
+++ b/compact_str/src/repr/boxed/capacity.rs
@@ -2,8 +2,21 @@ use crate::repr::HEAP_MASK;
// how many bytes a `usize` occupies
const USIZE_SIZE: u... | 4 | 102 | 2 |
5b0c6cfcad2fe39aaab94f301ca9959696e0a1f9 | Kalle Samuels | 2022-07-14T14:12:37 | add AddAssign operator (#159) | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 7572c1c2..fc6da69d 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -14,6 +14,7 @@ use core::hash::{
use core::iter::FromIterator;
use core::ops::{
Add,
+ AddAssign,
Bound,
Deref,
DerefMut,
@@ -1054,6 +1055,12... | 2 | 14 | 0 |
076ed82ba566577ff516e7100aa7e3fb7ac38330 | René Kijewski | 2022-07-06T22:23:53 | Deduplicate `CompactString::push()`
It's simply encoding the character as a UTF-8 sequence, then appending
the sequence. So `push()` can simply call `push_str()`. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 68de63ae..ed234a6c 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -439,9 +439,8 @@ impl CompactString {
///
/// assert_eq!("foobar", s);
/// ```
- #[inline]
pub fn push(&mut self, ch: char) {
- self.rep... | 2 | 3 | 31 |
bae0313aa0a7ea85644efb522c69e179e8b1a524 | René Kijewski | 2022-07-11T03:47:33 | Implement `split_off()` (#154)
* Implement `split_off()`
Closes #145. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 0cebdf7d..68de63ae 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -757,6 +757,29 @@ impl CompactString {
unsafe { self.set_len(0) };
}
+ /// Split the [`CompactString`] into at the given byte index.
+ ///
+ ... | 2 | 35 | 0 |
cf7cfb09e5c4e8a95a534da776bcec80f7c07b31 | René Kijewski | 2022-07-04T10:45:33 | Implement `drain()`
Closes #134. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 21704003..0cebdf7d 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -37,6 +37,7 @@ use core::str::{
};
use std::borrow::Cow;
use std::ffi::OsStr;
+use std::iter::FusedIterator;
mod asserts;
mod features;
@@ -755,6 +756,41 @@ im... | 2 | 139 | 0 |
9f6b5b4868e1177a20bf8002207187b7ff13012a | René Kijewski | 2022-07-04T10:11:52 | Make replace_range() reusable | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 71429dfa..21704003 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -515,6 +515,45 @@ impl CompactString {
self.repr.is_heap_allocated()
}
+ /// Ensure that the given range is inside the set data, and that no codepo... | 1 | 92 | 88 |
045f8e22963e2c6b1ef192cdc192f0af3adcd5e5 | Parker Timmerman | 2022-07-02T14:34:36 | update doc test for CompactString::clear(), assert capacity doesn't change | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 961b4d01..71429dfa 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -740,9 +740,13 @@ impl CompactString {
///
/// ```
/// # use compact_str::CompactString;
- /// let mut s = CompactString::new("Hello, world!");
+ ... | 1 | 5 | 1 |
2c8751841c09fbf1aa7a38be8e62e42c6dcbf5ca | René Kijewski | 2022-07-02T03:00:19 | Implement `clear()` | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 20c54063..961b4d01 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -733,6 +733,20 @@ impl CompactString {
pub fn insert(&mut self, idx: usize, ch: char) {
self.insert_str(idx, ch.encode_utf8(&mut [0; 4]));
}
+
+ ... | 2 | 23 | 0 |
dae951c36598de7b2229440c5bf2cf9758f16feb | René Kijewski | 2022-06-30T12:59:33 | Simplify getting an arbitrary index | diff --git a/fuzz/src/actions.rs b/fuzz/src/actions.rs
index 5a93123b..8d03794e 100644
--- a/fuzz/src/actions.rs
+++ b/fuzz/src/actions.rs
@@ -107,20 +107,8 @@ impl Action<'_> {
}
ReplaceRange(start, end, replace_with) => {
// turn the arbitrary numbers (start, end) into chara... | 1 | 15 | 35 |
7a69d80432741f1bf6b1536257d591dfeaaa496a | René Kijewski | 2022-06-30T12:24:21 | Implement `insert()` and `insert_str()`
Closes #139, #140. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index ef5851f8..20c54063 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -679,6 +679,60 @@ impl CompactString {
pub fn as_mut_ptr(&mut self) -> *mut u8 {
unsafe { self.repr.as_mut_slice().as_mut_ptr() }
}
+
+ /// Inse... | 3 | 171 | 0 |
ae5f2bc02261c7b28b8448e1e26e9b6eaf0191e0 | René Kijewski | 2022-06-30T11:50:30 | Check for overflow in `reserve()` | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index 03400fc0..e44da9af 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -161,7 +161,10 @@ impl Repr {
#[inline]
pub fn reserve(&mut self, additional: usize) {
// We want at least enough capacity to s... | 1 | 4 | 1 |
60ba04ad6c54749ee05f0672a15bd24c5dcac7df | René Kijewski | 2022-06-30T13:31:00 | Implement `as_ptr()` and `as_mut_ptr()`
The methods are safe, because dereferencing pointers is not possible in
a safe context. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index d4b22858..ef5851f8 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -667,6 +667,18 @@ impl CompactString {
);
unsafe { self.set_len(new_len) };
}
+
+ /// Converts a [`CompactString`] to a raw pointer.
+ #[... | 1 | 12 | 0 |
7550ba77d54113725f68136c86862ea9c03c480d | Parker Timmerman | 2022-06-30T05:10:51 | Implement the Arbitrary trait for:
* abritrary
* proptest
* quickcheck
Add sanity tests to make sure the implementations work, and strings are lined when we expect | diff --git a/compact_str/Cargo.toml b/compact_str/Cargo.toml
index f35411bf..99ebb980 100644
--- a/compact_str/Cargo.toml
+++ b/compact_str/Cargo.toml
@@ -12,7 +12,10 @@ keywords = ["string", "compact", "small", "memory", "mutable"]
categories = ["encoding", "parsing", "memory-management", "text-processing"]
[depen... | 5 | 169 | 0 |
0ccc6385fd3861180843a1481c113aa226e1fb1b | Parker Timmerman | 2022-06-30T01:31:49 | add more unit tests for truncate(...) | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index 7c354238..e31f4574 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -187,6 +187,38 @@ fn proptest_extend_chars_allocated_properly(
assert_allocated_properly(&compact);
}
+#[proptest]
+#[cfg_attr(miri, ignore)]
+fn prop... | 1 | 57 | 0 |
d94caeb86a8c7f319b32618b0da65dc9fe290e15 | René Kijewski | 2022-06-28T21:28:34 | Implement `truncate()`
Closes #131. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 76caf34f..d4b22858 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -634,6 +634,39 @@ impl CompactString {
}
}
}
+
+ /// Truncate the [`CompactString`] to a shorter length.
+ ///
+ /// If the length... | 2 | 52 | 0 |
a8066e963768154904cff07164e94919756cbc19 | Parker Timmerman | 2022-06-27T02:43:26 | small update to tests | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index c9a976ee..7c354238 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -386,8 +386,10 @@ fn test_plus_operator() {
// String + &CompactString
assert_eq!(String::from("a") + &CompactString::from("b"), "ab");
- // St... | 1 | 3 | 1 |
7d723e55eae4454907fe88992667ff15976de7ab | Parker Timmerman | 2022-06-27T02:25:57 | Modified our Add<T> impls:
* removed Add<CompactString> for String, because it broke adding some types to String
* remove all Add<T> for CompactString types, besides Add<&str> for CompactString, which actually allows us to add _more_ string types | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 5fb8f89f..76caf34f 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -879,22 +879,6 @@ impl fmt::Write for CompactString {
}
}
-impl Add<Self> for CompactString {
- type Output = Self;
- fn add(mut self, rhs: Self) -> Sel... | 2 | 19 | 43 |
1c7395a523979ed00c292fdfb8b527eccada9375 | Parker Timmerman | 2022-06-26T22:07:19 | branch start, reduce size of strings generated with CollectChars | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index f76e6f2d..084c185b 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -187,7 +187,7 @@ fn proptest_extend_chars_allocated_properly(
}
#[test]
-fn proptest_const_creation() {
+fn test_const_creation() {
const EMPTY: Comp... | 2 | 7 | 14 |
714785d90590f42c55df1a0a1f547006b0e730e9 | René Kijewski | 2022-06-24T13:50:48 | Implement `replace_range()`
This PR implments `CompactString::replace_range()` to work the same way
as the method in String of the same name. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 190d7f30..5fb8f89f 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -26,8 +26,10 @@ use core::hash::{
use core::iter::FromIterator;
use core::ops::{
Add,
+ Bound,
Deref,
DerefMut,
+ RangeBounds,
};
use core::s... | 2 | 149 | 0 |
9ac494d75f6050041865910cde34305bda410e68 | Parker Timmerman | 2022-06-25T14:37:53 | cargo fmt | diff --git a/fuzz/src/bin/honggfuzz.rs b/fuzz/src/bin/honggfuzz.rs
index 48de25b0..39661561 100644
--- a/fuzz/src/bin/honggfuzz.rs
+++ b/fuzz/src/bin/honggfuzz.rs
@@ -8,4 +8,4 @@ fn main() {
scenario.run();
});
}
-}
\ No newline at end of file
+} | 1 | 1 | 1 |
13882b91e961ac7e884915a880eb426932824269 | René Kijewski | 2022-06-24T12:34:58 | Add `as_mut_str()` method
`String::as_mut_str()` returns a mutable slice of its contents. This PR
adds the same method to CompactString.
The method is safe, because no safe operation on `&mut str` can result
in a broken UTF-8 string. | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 602caaf2..190d7f30 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -13,7 +13,10 @@
//! and capacity on the stack, you store the string itself! This avoids the need to heap allocate
//! which reduces the amount of memory used, and i... | 2 | 44 | 1 |
c40cc32786ede9757f67b2fbf58e7e8363db94de | Parker Timmerman | 2022-06-22T01:01:56 | whoops, forgot to add honggfuzz file | diff --git a/fuzz/src/bin/honggfuzz.rs b/fuzz/src/bin/honggfuzz.rs
new file mode 100644
index 00000000..48de25b0
--- /dev/null
+++ b/fuzz/src/bin/honggfuzz.rs
@@ -0,0 +1,11 @@
+use compact_str_fuzz::Scenario;
+use honggfuzz::fuzz;
+
+fn main() {
+ loop {
+ fuzz!(|scenario: Scenario<'_>| {
+ // run ... | 1 | 11 | 0 |
a58b86d65c48556a09dcb7d31fdcc6cf112cf86c | Parker Timmerman | 2022-06-22T00:57:06 | branch start, add honggfuzz target | diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index df7dc3cd..3d64d3a1 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -15,6 +15,7 @@ compact_str = { path = "../compact_str", features = ["bytes"] }
# Fuzz with both AFL++ and libFuzzer
afl = { version = "0.12.1", optional = true }
+honggfuzz = { version = "0.... | 1 | 8 | 0 |
d007d3aa4ece24f1e53533ed4a09b860c52459ac | Parker Timmerman | 2022-06-21T19:37:48 | cargo fmt | diff --git a/fuzz/src/lib.rs b/fuzz/src/lib.rs
index 87a500d6..65d4c282 100644
--- a/fuzz/src/lib.rs
+++ b/fuzz/src/lib.rs
@@ -41,7 +41,7 @@ impl<'a> Scenario<'a> {
// after making all of our modifications, assert again that we don't misinterpret
let compact = assert_not_option(compact);
- ... | 1 | 1 | 1 |
2eb7ce4c2f9016ce60fa583da05bfbde7403aca0 | Marcus Griep | 2022-06-21T12:34:00 | test: speed up miri test runs
By using `String::from_utf8_unchecked` we significantly speed up miri test
runs. This is because miri doesn't need to spend a ton of time verifying
that every character in the ~16MiB vector is UTF-8, when we already know
that it is, since it's always just ASCII `A`s. | diff --git a/compact_str/src/repr/boxed/mod.rs b/compact_str/src/repr/boxed/mod.rs
index 1f724e2d..f5f1fb73 100644
--- a/compact_str/src/repr/boxed/mod.rs
+++ b/compact_str/src/repr/boxed/mod.rs
@@ -612,8 +612,10 @@ mod tests {
fn test_32_bit_max_inline_cap() {
// 65 is the ASCII value of 'A'
// ... | 1 | 12 | 6 |
4c2e0263e241237d13664e47d09d99e5be13cf41 | Marcus Griep | 2022-06-21T01:44:24 | fix: properly handle the 32-bit case with boxed capacity | diff --git a/compact_str/src/repr/boxed/mod.rs b/compact_str/src/repr/boxed/mod.rs
index b148f1cd..1f724e2d 100644
--- a/compact_str/src/repr/boxed/mod.rs
+++ b/compact_str/src/repr/boxed/mod.rs
@@ -153,16 +153,21 @@ impl BoxString {
#[inline]
pub fn into_string(self) -> String {
- // Ensure that we ... | 3 | 52 | 17 |
ce5fbd3f52bb44284f096b9d9f20add82055f933 | Marcus Griep | 2022-06-19T16:54:53 | fix: handling of boxed capacity on 32-bit arch | diff --git a/compact_str/src/repr/boxed/mod.rs b/compact_str/src/repr/boxed/mod.rs
index 06e77cd2..b148f1cd 100644
--- a/compact_str/src/repr/boxed/mod.rs
+++ b/compact_str/src/repr/boxed/mod.rs
@@ -162,10 +162,7 @@ impl BoxString {
// * `length` is less than or equal to capacity, due to internal invaraints.
... | 1 | 1 | 4 |
831c2a95f996f1fc6a847f9f9b4843c69a985546 | Marcus Griep | 2022-06-19T16:29:07 | feat: add impl From<CompactString> for String
Closes #117 | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index deccd4be..602caaf2 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -610,6 +610,12 @@ impl From<Box<str>> for CompactString {
}
}
+impl From<CompactString> for String {
+ fn from(s: CompactString) -> Self {
+ s.repr.... | 5 | 208 | 0 |
e39f30dafd1e89578609ad48272fa6aca29c9781 | Parker Timmerman | 2022-06-18T17:47:02 | remove bounds check when getting &str from inline variant
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Co-authored-by: Parker Timmerman <parker@parkertimmerman.com> | diff --git a/compact_str/src/repr/inline.rs b/compact_str/src/repr/inline.rs
index 0bd3d7fe..4332348f 100644
--- a/compact_str/src/repr/inline.rs
+++ b/compact_str/src/repr/inline.rs
@@ -73,8 +73,12 @@ impl InlineString {
#[inline]
pub fn as_str(&self) -> &str {
- // SAFETY: You can only construct an... | 1 | 6 | 2 |
36681876f7836d4ededfe20cb68a67c0af0f0280 | Parker Timmerman | 2022-06-18T17:40:27 | add examples | diff --git a/Cargo.toml b/Cargo.toml
index 64000f41..7f4c2204 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,2 +1,10 @@
[workspace]
-members = ["bench", "examples/bytes", "examples/serde", "compact_str", "fuzz"]
+members = [
+ "bench",
+ "examples/bytes",
+ "examples/macros",
+ "examples/serde",
+ "exam... | 5 | 77 | 1 |
1de22af0859588229b54ac9e204c407ca9af8aeb | Parker Timmerman | 2022-06-18T17:30:49 | branch start, small cleanup in inline.rs | diff --git a/compact_str/src/repr/inline.rs b/compact_str/src/repr/inline.rs
index 5c1de419..0bd3d7fe 100644
--- a/compact_str/src/repr/inline.rs
+++ b/compact_str/src/repr/inline.rs
@@ -32,12 +32,7 @@ impl InlineString {
#[inline]
pub const fn new_const(text: &str) -> Self {
if text.len() > MAX_SIZE... | 1 | 3 | 8 |
b87a436364227f2653f2a70e765739645b406ce2 | Parker Timmerman | 2022-06-18T17:15:57 | cargo fmt | diff --git a/compact_str/src/tests.rs b/compact_str/src/tests.rs
index b42dba63..80c844ee 100644
--- a/compact_str/src/tests.rs
+++ b/compact_str/src/tests.rs
@@ -76,7 +76,9 @@ fn proptest_char_iterator_roundtrips(#[strategy(rand_unicode())] word: String) {
#[proptest]
#[cfg_attr(miri, ignore)]
-fn proptest_string_... | 1 | 3 | 1 |
e849e63edd44c98eb8240dfbd1c60e86a0a20d81 | Parker Timmerman | 2022-06-18T17:15:23 | rename all tests that use proptest to proptest_*, get rid of patched versions of abritrary and test-strategy | diff --git a/Cargo.toml b/Cargo.toml
index 778ba86a..64000f41 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,9 +1,2 @@
[workspace]
members = ["bench", "examples/bytes", "examples/serde", "compact_str", "fuzz"]
-
-[patch.crates-io]
-# there's currently a bug with `arbitrary` that causes panics on 32-bit archs when the... | 8 | 45 | 52 |
d0bea256ff33e859a0166efb526f38fcf231f241 | Parker Timmerman | 2022-06-18T16:31:43 | branch start, prep for v0.5 release by removing the CompactStr type alias | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index c4558883..86a6ef09 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -89,17 +89,6 @@ pub struct CompactString {
repr: Repr,
}
-/// # DEPRECATED
-/// Renamed `CompactStr` to [`CompactString`]. Using the suffix "String" as oppose... | 1 | 0 | 11 |
2b33edada2da4e9fc584a155ca73c1de9a586d5a | Parker Timmerman | 2022-06-18T06:32:05 | update lifetimes and reference for trait impl, update trait docs, cargo fmt | diff --git a/compact_str/src/traits.rs b/compact_str/src/traits.rs
index 27ca319a..e8ff4d4a 100644
--- a/compact_str/src/traits.rs
+++ b/compact_str/src/traits.rs
@@ -114,68 +114,69 @@ impl<T: fmt::Display> ToCompactString for T {
}
}
-/// A trait that provides convience methods for creating a [`CompactString`]... | 2 | 34 | 33 |
c7514477c59a2c614dbe8a9d83e498d4f913bd78 | Parker Timmerman | 2022-06-18T05:02:29 | add proptests and fuzz testing | diff --git a/compact_str/src/traits.rs b/compact_str/src/traits.rs
index 03dc3e52..27ca319a 100644
--- a/compact_str/src/traits.rs
+++ b/compact_str/src/traits.rs
@@ -200,25 +200,48 @@ mod tests {
use proptest::prelude::*;
use test_strategy::proptest;
+ use crate::CompactString;
use super::{
... | 2 | 52 | 6 |
92002e7dbcd0b0abc4cf53734a2d72c13f9a023c | Parker Timmerman | 2022-06-18T04:48:52 | improve lifetime and reference requirements for the impl, improve docs | diff --git a/compact_str/src/traits.rs b/compact_str/src/traits.rs
index 3f3e3984..03dc3e52 100644
--- a/compact_str/src/traits.rs
+++ b/compact_str/src/traits.rs
@@ -114,15 +114,36 @@ impl<T: fmt::Display> ToCompactString for T {
}
}
+/// A trait that provides convience methods for creating a [`CompactString`]... | 1 | 42 | 10 |
04efb60ddf4755a268a35f7fab5c6c30447a4aeb | Parker Timmerman | 2022-06-18T01:55:16 | branch start, define the CompactStrExt trait, and basic tests and impls | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index c4558883..76281799 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -41,7 +41,10 @@ mod repr;
use repr::Repr;
mod traits;
-pub use traits::ToCompactString;
+pub use traits::{
+ CompactStringExt,
+ ToCompactString,
+};
#[c... | 2 | 71 | 2 |
00683c19fa6249d514783b3da0a8d9761289a30e | Parker Timmerman | 2022-06-18T00:18:15 | branch start, optimize fmt::Write
Co-authored-by: René Kijewski <rene.kijewski@fu-berlin.de>
Co-authored-by: Parker Timmerman <parker@parkertimmerman.com> | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index d75c0428..c4558883 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -713,6 +713,16 @@ impl fmt::Write for CompactString {
self.push_str(s);
Ok(())
}
+
+ fn write_fmt(mut self: &mut Self, args: fmt::Arguments<... | 2 | 20 | 0 |
bb28b7a736853ce0c780519887f06ef444842423 | Parker Timmerman | 2022-06-17T18:00:23 | cargo fmt | diff --git a/compact_str/src/repr/mod.rs b/compact_str/src/repr/mod.rs
index eb101688..5cfc114c 100644
--- a/compact_str/src/repr/mod.rs
+++ b/compact_str/src/repr/mod.rs
@@ -24,7 +24,6 @@ use discriminant::{
use heap::HeapString;
use inline::InlineString;
use nonmax::NonMaxU8;
-
pub use traits::IntoRepr;
pub co... | 2 | 9 | 10 |
43ee01319cd88ea1e9fd1580f01124b7a91c1b7a | Jiahao XU | 2022-06-10T03:56:06 | Add macro_rules `format_compact!` (#101)
* Add macro_rules `format_compact!`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Update doc of `format_compact!`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Fix `format_compact!` impl and its unit test case
Signed-off-by: Jiahao XU <Jiahao_XU@outlook... | diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs
index 627904af..e1aae6ef 100644
--- a/compact_str/src/lib.rs
+++ b/compact_str/src/lib.rs
@@ -34,6 +34,7 @@ use std::ffi::OsStr;
mod asserts;
mod features;
+mod macros;
mod utility;
mod repr;
diff --git a/compact_str/src/macros.rs b/compact_str/src/ma... | 2 | 45 | 0 |
c457f0236c62c563902d6f86a84c5088e5ba3772 | Parker Timmerman | 2022-06-10T03:34:36 | branch start, update examples to v0.4 (#99) | diff --git a/examples/bytes/Cargo.toml b/examples/bytes/Cargo.toml
index d26fb4ac..5602a09d 100644
--- a/examples/bytes/Cargo.toml
+++ b/examples/bytes/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2018"
[dependencies]
bytes = "1"
-compact_str = { version = "0.3", features = ["bytes"] }
+compact_str = { version = "0.4", fe... | 4 | 9 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.