Commit Graph

136 Commits

Author SHA1 Message Date
Lukas Wirth
28b9403e15 Bump deps 2024-09-02 20:42:14 +02:00
Rob Ede
c1327b21ba Migrate CI to actions-rust-lang/setup-rust-toolchain 2024-06-01 10:06:49 +02:00
Rob Ede
5146c928fd Document crate feature guards 2024-06-01 10:06:30 +02:00
Lukas Wirth
7cb89f14c6 Publish 0.2.2 2024-05-14 10:15:12 +02:00
Lukas Wirth
89a555b9b5 Document unsafe blocks 2024-05-14 10:09:33 +02:00
Alex Butler
860343ab85 Add StrExt::replace_smolstr, replacen_smolstr 2024-04-18 10:08:01 +02:00
Arpad Borsos
29f5ba6318 Add PartialEq shortcut for ptr_eq strings
This first compares the `Repr` before falling back to actually comparing the raw `as_str` itself.
In some micro-benchmarks, this speeds up inline and heap string comparisons when equal by ~70%.

There is a tiny hit in the non-equal case however. It is also noteworthy that the assembly generated for `Repr` is horrible,
and looks like its above the inlining threshold now.
2024-02-08 22:42:21 +01:00
Alex Butler
da4eb11ce9 Add must_use to StrExt methods 2024-02-08 22:41:25 +01:00
Alex Butler
79bb5e39b5 Add StrExt, to_lowercase_smolstr & friends 2024-02-08 14:43:17 +01:00
Anton Sol
2235939297 reformat 2024-01-31 18:59:27 +01:00
Anton Sol
257ece4d73 remove nightly benchmark feature 2024-01-31 18:59:27 +01:00
Anton Sol
1f338f7d8c Manually impl clone 2024-01-31 18:59:27 +01:00
Anton Sol
6df2f06299 fix clone regression
test bench::bench_derive_clone ... bench:     454,318 ns/iter (+/- 11,401)
test bench::bench_match_clone  ... bench:     183,570 ns/iter (+/- 10,652)
test bench::bench_new_clone    ... bench:     177,907 ns/iter (+/- 2,234)
2024-01-31 18:59:27 +01:00
Anton Sol
471f1b6137 add benchmarks
This regressed from a previous attempt.
The worst of the old results were in the range 450.000

current:

test bench::bench_derive_clone ... bench:   1,653,247 ns/iter (+/- 32,781)
test bench::bench_match_clone  ... bench:   1,716,482 ns/iter (+/- 34,192)
test bench::bench_new_clone    ... bench:   1,717,985 ns/iter (+/- 52,137)
2024-01-31 18:59:27 +01:00
Lukas Wirth
13cac19135 Publish 0.2.1 2024-01-16 10:58:18 +01:00
novacrazy
ebb96d259d Fix new_inline codegen 2024-01-16 10:53:13 +01:00
novacrazy
5559e23a50 Cleanup 2024-01-16 10:53:13 +01:00
novacrazy
39257f6b05 Add Writer and ToSmolStr 2024-01-16 09:18:52 +01:00
Moulins
f93c6b2cb0 feat: Add SmolStr::from_static
Allows creating `SmolStr`s longer than 23 bytes in constant
contexts.

This is done by replacing the `Repr::Substring` variant by a more
general `Repr::Static(&'static str)` variant, and borrowing from ̀`WS`
directly instead of storing two `usize`s.

As a bonus, it also simplifies the `as_str` implementation, hopefully
saving an extra branch.
2024-01-11 15:45:38 +01:00
Lukas Wirth
525832c476 Merge pull request rust-analyzer/smol_str#59 from MultisampledNight/fix-missing-backtick 2023-09-22 07:41:46 +02:00
MultisampledNight
8797f4fdfb docs: fix missing codeblock backtick 2023-09-20 18:26:08 +02:00
Lukas Wirth
05052c48e4 Merge pull request rust-analyzer/smol_str#58 from msdrigg/master 2023-09-10 09:03:32 +02:00
Scott Driggers
0eed716dcc Enforcing stack if can be put on stack 2023-09-05 14:45:32 -04:00
Scott Driggers
ced7e87db1 Implementing From<Arc<str>> for SmolStr and From<SmolStr> for Arc<str>
Also adding one test to verify
2023-08-25 09:39:14 -04:00
Lukas Wirth
b04898eb32 Merge pull request rust-analyzer/smol_str#55 from rust-analyzer/as-ref 2023-04-11 14:09:31 +02:00
Lukas Wirth
ea478f81f1 Release 0.2.0 2023-03-31 07:38:34 +02:00
Lukas Wirth
4ad02f720f Clarify size of SmolStr better 2023-03-31 07:37:08 +02:00
Lukas Wirth
8f9fefd8a0 Implement AsRef<str> in favor of generic From impls 2023-03-31 07:33:19 +02:00
Lukas Wirth
fef9abc8f1 Merge pull request rust-analyzer/smol_str#54 from rust-analyzer/opt-dep-feat 2023-03-30 17:37:45 +02:00
Lukas Wirth
ae67412164 Use optional dependency feature syntax to make serde actually optional 2023-03-30 17:36:41 +02:00
Lukas Wirth
3dc956388e Merge pull request rust-analyzer/smol_str#53 from Austaras/master
Closes https://github.com/rust-analyzer/smol_str/issues/45
2023-02-05 08:18:37 +01:00
austaras
5f367d76ae Update test 2023-02-05 08:15:53 +08:00
austaras
46e5bd0097 Remove redundant enum value 2023-01-24 18:03:45 +08:00
austaras
8eced95f00 Update README.MD 2023-01-23 21:19:58 +08:00
austaras
ec90e593f3 0.1.24 2023-01-23 18:57:29 +08:00
austaras
c5a4d2475e One more byte for inlined 2023-01-23 18:06:21 +08:00
Lukas Wirth
25d7fa7105 Revert usage of optional dependency feature syntax 2022-04-26 23:59:49 +02:00
bors[bot]
dc5a62b1ef Merge rust-analyzer/smol_str#46
46: Use new optional dependency feature syntax making serde truly optional r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/smol_str/issues/42
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-08 19:05:48 +00:00
Lukas Wirth
844ee7798d Use new optional dependency feature syntax making serde truly optional 2022-04-08 21:05:25 +02:00
bors[bot]
97445cc17f Merge rust-analyzer/smol_str#44
44: Bump dependencies r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-03 14:19:42 +00:00
Lukas Wirth
fa9d3154e9 Bump dependencies 2022-04-03 16:19:14 +02:00
bors[bot]
d025e36945 Merge rust-analyzer/smol_str#43
43: Clarify what `WS` is r=Veykril a=Veykril

Closes https://github.com/rust-analyzer/smol_str/issues/17
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-03 14:10:31 +00:00
Lukas Wirth
a956245171 Clarify what WS is 2022-04-03 16:10:03 +02:00
bors[bot]
0b808e8a37 Merge rust-analyzer/smol_str#18
18: Add fmt tidy test r=Veykril a=Atul9



Co-authored-by: Atul Bhosale <atul1bhosale@gmail.com>
2022-04-03 14:06:06 +00:00
bors[bot]
a898cf57a7 Merge rust-analyzer/smol_str#21
21: Add a new test for a bad size hint r=bjorn3 a=Dr-Emann

Changes in PR rust-analyzer/smol_str#20 allow for an incorrect size hint to create a non-canonical SmolStr. Add a new test which will fail if we ever rely on
SmolStrs to be canonical when comparing for equality.

Co-authored-by: Zachary Dremann <dremann@gmail.com>
2022-03-11 06:30:54 +00:00
Zachary Dremann
77c6c2b2ae Use ASCII to get the "too big" char iterator
Additionally, make the construction of the string mechanical
2022-03-10 19:29:45 -05:00
Zachary Dremann
a1cbd1feee Add a new test for bad size hint
Changes in PR rust-analyzer/smol_str#20 allow for an incorrect size hint to create a
non-canonical SmolStr. Add a new test which will fail if we ever rely on
SmolStrs to be canonical when comparing for equality.
2022-03-10 19:29:45 -05:00
bors[bot]
5fb30ef6ac Merge rust-analyzer/smol_str#41
41: Remove unnecessary `Into<String>` bound from `From<T>` impl r=Veykril a=Veykril

Looks like this was forgotten when the bound got removed from the `new` constructor

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-04 18:11:13 +00:00
Lukas Wirth
7771472941 Remove unnecessary Into<String> bound from From<T> impl 2021-11-04 18:43:01 +01:00
bors[bot]
4916033264 Merge rust-analyzer/smol_str#40
40: fix no_std support r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-11-01 13:05:10 +00:00