Michael Pfaff
d97885392b
Silence unused_macros on render_tuple!
2024-03-14 23:02:19 -04:00
Michael Pfaff
19a740f26c
impl RenderOnce on tuples of up to 8 values
2024-03-14 23:01:39 -04:00
Michael Pfaff
4e2232f2de
Unify Render* and Template* traits
2024-03-11 17:33:11 -04:00
Michael Pfaff
e5a471d9ca
Improve API
2024-03-11 16:57:52 -04:00
Kogia-sima
a88aacbc9e
perf: improve buffer performance
...
* Use reserve_small in push_str method
* revert 47818c1
to avoid unnecessary reloading of length
2021-03-29 08:19:13 +09:00
Kogia-sima
47818c11b7
perf: Use same reallocation strategy as Vec
...
This change seems to improve performance on some benchmarks (e.g.
techempower), but causes performance regression on another benchmark. We
need to measure performance using more test cases.
2021-02-03 00:50:24 +09:00
Kogia-sima
67f49bdd18
Avoid calling custom memcpy implementation on some platforms
...
Custom memcpy implementation performs well on the platforms on which
unaligned read/write operation is fast. Otherwise we should use libc
implementation.
2021-01-25 19:54:58 +09:00
Kogia-sima
000e971fa3
refactor: Use `inline` instead of `inline(always)`
2021-01-11 17:23:23 +09:00
Kogia-sima
30f42f1b46
refactor: Implement faster `render_escaped` method for upper filter
2021-01-11 17:23:23 +09:00
Kogia-sima
e69d36b168
refactor: clippy fix
2020-12-29 16:53:46 +09:00
Kogia-sima
25fed05519
test: improve test coverage for runtime
2020-12-29 04:51:08 +09:00
Kogia-sima
2d6b29da6f
test: Add more tests
2020-12-29 01:32:56 +09:00
Kogia-sima
6c2ef0deae
test: simplify filter tests
2020-12-28 22:44:36 +09:00
Kogia-sima
46fa250c49
feat: allow unsized types for filters
2020-12-28 22:33:49 +09:00
Kogia-sima
28ca4e2959
doc: fix examples in doc comments
2020-12-28 21:28:53 +09:00
Kogia-sima
3ee7d06024
refactor: fmt
2020-12-24 15:50:26 +09:00
Kogia-sima
dca8048bd0
perf: Do not compile runtime feature detection on avx2
...
This feature detection may avoid inlining avx2::escape function
2020-12-24 15:06:01 +09:00
Kogia-sima
54f77cc25a
Add debug_assert for Buffer::_set_len
2020-12-24 15:00:19 +09:00
Kogia-sima
d127eba2ee
fix: Fix compilation issue with Cow<'a, str>
2020-12-21 17:02:32 +09:00
Kogia-sima
034e7dad45
fix: Fix compilation error due to missing docs
2020-12-20 22:11:13 +09:00
Kogia-sima
8deecff5fe
break: change RenderError into enum
2020-12-20 21:55:55 +09:00
Kogia-sima
b58a51a1ae
doc: deny missing docs
2020-12-20 21:23:47 +09:00
Kogia-sima
b6e0f145fa
doc: Examples for filters
2020-12-20 21:23:47 +09:00
Kogia-sima
bbb16e0e14
perf: New size hint strategy
2020-12-20 20:21:18 +09:00
Kogia-sima
f236a98fed
perf: reduce memcpy call in HTML escaping
2020-12-20 19:33:13 +09:00
Kogia-sima
36281a7da6
doc: doc comments for buffer methods
2020-12-20 18:23:32 +09:00
Kogia-sima
8cc19b72b8
doc: Document unsafety of Render trait
2020-12-20 16:31:04 +09:00
Kogia-sima
5ceb904f19
fix: Fix unsoundness issue on truncate filter
...
old implementation of truncate filter is unsound because it may calls
Buffer::set_len() for the index which does not on the char boundary when
buffer sized decreased.
2020-12-20 16:07:06 +09:00
Kogia-sima
7a6b164e9e
fix: Remove unsafe usage of ptr::add()
...
offset passed to add() method must not overflow isize::MAX
2020-12-20 12:16:45 +09:00
Kogia-sima
8de885a4cf
fix: Remove incorrect debug_assert
2020-12-19 21:45:26 +09:00
Kogia-sima
e1d7c388f5
perf: branch hint in Buffer::reserve
2020-12-19 21:07:09 +09:00
Kogia-sima
fa198107a0
fix: Do not panic when buffer size decreased
2020-12-19 20:42:03 +09:00
Kogia-sima
ee1952c2eb
feat: impl Send/Sync for Buffer
2020-12-19 18:21:48 +09:00
Kogia-sima
c6a3985dfd
perf: optimize simd escaping for small strings
2020-12-19 16:58:36 +09:00
Kogia-sima
bf55dd7909
Branch optimization in naive escape
2020-12-18 18:28:21 +09:00
Kogia-sima
fe11aff782
Merge branch 'feature/json-filter'
2020-12-18 12:24:43 +09:00
Kogia-sima
d381552e6b
feat: truncate filter
2020-12-18 11:13:14 +09:00
Kogia-sima
e899e99ea1
doc: json filter documentation
2020-12-17 19:47:33 +09:00
Kogia-sima
d7bce02109
feat: json filter
2020-12-17 19:47:27 +09:00
Kogia-sima
daa6f4878d
Rename some tests
2020-12-17 16:30:47 +09:00
Kogia-sima
e316c82eb5
Remove String::truncate()
...
Current implementation is unsafe because it doesn't check if `new_len`
does lie on a char boundary.
2020-12-17 16:24:57 +09:00
Kogia-sima
53a9cb9713
fix error with cargo-miri
2020-12-17 15:38:11 +09:00
Kogia-sima
5961a7400b
security: Properly handle slices with size greater than isize::MAX
...
See https://github.com/rust-lang/rust/pull/79930#issuecomment-747135498
for more details.
2020-12-17 10:24:28 +09:00
Kogia-sima
5108988879
Use std::isize::MAX instead of isize::MAX
...
isize::MAX not working on Rust 1.42.0
2020-12-17 10:09:18 +09:00
Kogia-sima
a5f40fe270
Revert "refactor: Use nanorand crate instead of custom xorshift implementation"
...
This reverts commit d0ec00fb29
.
I found that nanorand crate does not work on Mac OSX.
2020-12-17 10:07:53 +09:00
Kogia-sima
c182e41622
perf: Optimize Buffer::push()
...
fix #8
2020-12-16 21:52:39 +09:00
Kogia-sima
aa0afb1f81
doc: Update safety documents
...
and some assertion fix
2020-12-16 21:17:06 +09:00
Kogia-sima
790f7366cf
break: Update TemplateOnce trait structure
...
* Remove render_once_to_string method
* Add render_once_to method
* Now TemplateOnce trait requires both method implementation
* Some performance improvement
2020-12-16 19:01:28 +09:00
Kogia-sima
d0ec00fb29
refactor: Use nanorand crate instead of custom xorshift implementation
2020-12-16 16:52:07 +09:00
Kogia-sima
9b733f973f
suppress dead_code warning when target_feature = "avx2"
2020-12-16 15:44:20 +09:00
Kogia-sima
c7093a727a
perf: Replace reserve with reserve_small
2020-12-16 15:18:04 +09:00
Kogia-sima
72b061ee3e
refactor: Use unlikely in Buffer::reserve()
2020-11-30 12:19:03 +09:00
Kogia-sima
c9b4d08ed0
refactor: hide Buffer::clear() method
...
This method is dangerous because it might deletes all contents
previouslly rendered.
2020-11-21 18:44:56 +09:00
Kogia-sima
834289be59
refactor: Reduce unsafe blocks
2020-11-21 18:44:52 +09:00
Kogia-sima
82fb9f5469
refactor: Remove unused code
2020-11-21 18:25:36 +09:00
Kogia-sima
d79a5d3b4b
perf: Zero-copy conversion from String into Buffer
2020-08-04 03:14:21 +09:00
Kogia-sima
4a8ce80e3d
improve escape_small() performance
2020-07-23 11:49:53 +09:00
Kogia-sima
cc10171b73
Avoid dangerous conversion from String to Buffer
2020-07-22 07:05:15 +09:00
Kogia-sima
fcde448751
Add trim filter
2020-07-22 06:40:26 +09:00
Kogia-sima
31bbcaebc8
Avoid capacity overflow in Buffer::with_capacity
2020-07-22 03:25:07 +09:00
Kogia-sima
236dff6b10
Improve size hint update algorithm
2020-07-21 09:00:15 +09:00
Kogia-sima
80b64fe883
break: Remove Buffer::set_len method
...
This method allows reducing the buffer size, but it should not be
possible.
Alternatively I added a Buffer::advance method to increase the length.
2020-07-15 19:49:35 +09:00
Kogia-sima
15b0504564
Add tests for filter
2020-07-15 19:34:53 +09:00
Kogia-sima
eac0dfbf5b
Add minimal runtime filters
2020-07-15 17:12:31 +09:00
Kogia-sima
670d936def
break: remove runtime::Context API
2020-07-15 00:06:01 +09:00
Kogia-sima
869c58dcb1
Use UFCS instead of receiver coecions
...
This change is required to achieve filter
2020-07-15 00:06:01 +09:00
Kogia-sima
203a890618
break: Remove register_escape_fn API
2020-07-15 00:06:01 +09:00
Kogia-sima
470f5b7ffa
Remove unreachable code
2020-07-14 20:37:20 +09:00
Kogia-sima
e277fe4a7d
Add more tests for runtime
2020-07-14 18:38:38 +09:00
Kogia-sima
f41047ef92
Optimize Buffer::push_str() implementation for stable compiler
2020-07-14 05:43:02 +09:00
Kogia-sima
b1f266a285
Fix buffer capacity overflow check
2020-07-13 06:47:19 +09:00
Kogia-sima
5d874e44ea
doc: update doc comments
2020-07-11 17:10:23 +09:00
Kogia-sima
b4903f2b3d
refactor: Add utils.rs
2020-07-11 04:23:39 +09:00
Kogia-sima
5cef362dbd
Add more debug assertions
2020-07-11 02:39:04 +09:00
Kogia-sima
277a71cd0f
Optimize long HTML escaping
2020-07-11 02:29:55 +09:00
Kogia-sima
eb438f6d3c
Fix safe_realloc implementation
2020-07-10 10:20:10 +09:00
Kogia-sima
28baf202c2
Hide SizeHint and Context from docs
2020-07-10 08:50:32 +09:00
Kogia-sima
6c21955189
Fix memcpy_small implementation to emulate glibc implenetation exactly
2020-07-10 07:38:06 +09:00
Kogia-sima
3043719d35
Fix default implementation of Render::render_escaped
2020-07-10 00:32:58 +09:00
Kogia-sima
7d0538b244
Fix HTML escaping in char rendering
2020-07-10 00:30:25 +09:00
Kogia-sima
6ab65f4247
Use itoap crate to render integers
2020-07-08 22:26:47 +09:00
Kogia-sima
d86a35cbd6
Fix Integer::MAX_LEN for usize and isize
2020-07-08 07:06:49 +09:00
Kogia-sima
b46ffbe623
Optimize write_u128 for small integers
2020-07-08 05:55:03 +09:00
Kogia-sima
636633331b
clippy
2020-07-05 13:33:56 +09:00
Kogia-sima
36be07bbc7
More compiler hints
2020-07-05 13:25:57 +09:00
Kogia-sima
8107bb84ca
perf: More powerful small escape optimization
2020-07-04 22:32:33 +09:00
Kogia-sima
b596baa69e
Implement small escape optimization
2020-07-03 01:58:50 +09:00
Kogia-sima
ea080e8a6c
impl Render for u128/i128
2020-06-20 21:21:51 +09:00
Kogia-sima
6cacdad287
feat: RenderError::new() method
2020-06-19 18:07:19 +09:00
Kogia-sima
be293c8f90
Update doc comments
2020-06-19 15:40:30 +09:00
Kogia-sima
7c97d4e0ff
Speedup floating point formatting
2020-06-18 17:51:59 +09:00
Kogia-sima
dd4d31a48c
Add new feature (perf-inline)
2020-06-18 17:28:10 +09:00
Kogia-sima
bc4bb47082
feat: register_escape_fn API
2020-06-18 17:25:04 +09:00
Kogia-sima
9a7f62e3ca
Improve buffering performance
2020-06-18 17:12:55 +09:00
Kogia-sima
0f88c943bf
fix: Handle capacity overflow
2020-06-18 00:49:59 +09:00
Kogia-sima
f094b0671d
Avoid using primitive::MIN/primitive::MAX
...
These associated constants is not supported in 1.42
2020-06-16 22:47:26 +09:00
Kogia-sima
0cfcb14624
refactor: Rename private trait method
2020-06-16 22:27:08 +09:00
Kogia-sima
9e2952d92d
Add Buffer::render_internal method to speedup reserve method
2020-06-16 20:00:35 +09:00
Kogia-sima
0f3d0f7705
Fix documentation about HTML escaping
2020-06-16 13:51:18 +09:00
Kogia-sima
1379f9b3b3
Escape single quote (')
...
It seems that EJS escapes this character.
2020-06-15 12:06:14 +09:00