b28c843
xmpp: Use the new FullJid::resource_str() method
Emmanuel Gil Peyrot
created
e659576
Use the parts/str split in FullJid and BareJid too
Click to expand commit body
Since 199b3ae7ae12f909b18fca188a121068b340f718 we allow typed parts to
be reused without stringprep being reapplied. This extends it from just
Jid to FullJid and BareJid too.
stringprep can make transformations to a JID, the most well-known one is
making the nodepart and domainpart lowercase but it does much more than
that.
It is extremely common to have to validate already-normalised JIDs
though, and since https://github.com/sfackler/rust-stringprep/pull/4
this is exactly what the stringprep crate does, by returning
Cow::Borrowed() for common ASCII-only cases.
This commit further reduces time spent by an additional -15%..-58% when
already using this stringprep improvement, in addition to the
89.5%..98.5% change brought by this improvement (and +1.3% total when
the JID isn’t normalised yet).
For instance, my own full JID parses in 1.83 µs before these changes,
132Â ns with just the stringprep optimisation, and 46Â ns with also this
commit, on an i7-8700K.
This needs to be a loop in order to ignore packets we don’t care about,
or those we want to handle elsewhere. Returning something isn’t correct
in those two cases because it would signal to tokio that the XMPPStream
is also done, while there could be additional packets waiting for us.
The proper solution is thus a loop which we exit once we have something
to return.
Fixes a deadlock when we ignore some packets.
Emmanuel Gil Peyrot
created
ac22765
tokio-xmpp: Remove newline after stream:stream
Click to expand commit body
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
The main reason for this refactor was to make common operations simpler,
for instance formatting a JID is now a simple clone of a String.
Instead of having three different String for each of node, domain and
resource, we now have a single String with offsets pointing to where the
at and slash are (if they are present).
This also reduces the size of a FullJid from 72Â bytes to 32Â bytes on
64-bit platforms (less so on 32-bit), and BareJid from 48Â bytes to
32Â bytes. Jid is still 40Â bytes instead of 32, but that can be improved
in a future version where InnerJid has been inlined into each struct.
Emmanuel Gil Peyrot
created
187e156
jid: Move JidParseError into its own module