bevy/crates/bevy_reflect/src
Nicola Papale 365cf3114a
Make the reflect path parser utf-8-unaware (#9371)
# Objective

All delimiter symbols used by the path parser are ASCII, this means we
can entirely ignore UTF8 handling. This may improve performance.

## Solution

Instead of storing the path as an `&str` + the parser offset, and
reading the path using `&self.path[self.offset..]`, we store the parser
state in a `&[u8]`. This allows two optimizations:

1. Avoid UTF8 checking on `&self.path[self.offset..]`
2. Avoid any kind of bound checking, since the length of what is left to
read is stored in the `&[u8]`'s reference metadata, and is assumed valid
by the compiler.

This is a major improvement when comparing to the previous parser.

1. `access_following` and `next_token` now inline in `PathParser::next`
2. Benchmarking show a 20% performance increase (#9364)

Please note that while we ignore UTF-8 handling, **utf-8 is still
supported**. This is because we only handle "at the edges" what happens
exactly before and after a recognized `SYMBOL`. utf-8 is handled
transparently beyond that.
2023-08-25 23:12:25 +00:00
..
enums bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
impls Implement reflect trait on new glam types (I64Vec and U64Vec) (#9281) 2023-07-31 19:18:21 +00:00
path Make the reflect path parser utf-8-unaware (#9371) 2023-08-25 23:12:25 +00:00
serde bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
array.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00
fields.rs bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
from_reflect.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00
lib.rs Make it so ParsedPath can be passed to GetPath (#9373) 2023-08-25 14:32:41 +00:00
list.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00
map.rs Fix CI for Rust 1.72 (#9562) 2023-08-25 12:34:24 +00:00
reflect.rs Reflect now requires DynamicTypePath. Remove Reflect::get_type_path() (#8764) 2023-06-06 17:23:58 +00:00
std_traits.rs fix nightly clippy warnings (#6395) 2022-10-28 21:03:01 +00:00
struct_trait.rs Fix CI for Rust 1.72 (#9562) 2023-08-25 12:34:24 +00:00
tuple.rs Reflect now requires DynamicTypePath. Remove Reflect::get_type_path() (#8764) 2023-06-06 17:23:58 +00:00
tuple_struct.rs Reflect now requires DynamicTypePath. Remove Reflect::get_type_path() (#8764) 2023-06-06 17:23:58 +00:00
type_info.rs Reflect now requires DynamicTypePath. Remove Reflect::get_type_path() (#8764) 2023-06-06 17:23:58 +00:00
type_path.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00
type_registry.rs Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
type_uuid.rs implement TypeUuid for primitives and fix multiple-parameter generics having the same TypeUuid (#6633) 2023-02-16 17:09:44 +00:00
type_uuid_impl.rs implement TypeUuid for primitives and fix multiple-parameter generics having the same TypeUuid (#6633) 2023-02-16 17:09:44 +00:00
utility.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00