Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the jid data structure #7

Merged
merged 2 commits into from
Apr 26, 2022
Merged

Simplify the jid data structure #7

merged 2 commits into from
Apr 26, 2022

Conversation

NelsonVides
Copy link
Collaborator

@NelsonVides NelsonVides commented Jan 29, 2022

Remove fields that should actually never be used. The idea is that the
non-normalised parts MUST actually have never been used for comparison,
and are therefore not really needed. If only for printing and using them
in the to and from attributes of a stanza, clients SHOULD also
stringprep anyway, so the fact that the server might provide
non-normalised strings might be a problem for clients who're not
enforced to normalise them.

I've also been verifying how many other XMPP implementations tackle this
issue, and I've seen many other servers, and also a bunch of client
frameworks, simply capturing the parts and normalising them, and
building data structures that keep only their normalised pieces.

Note, I imagine this to make for a version 2.0, as it contains kinda breaking changes. Libraries shouldn't be looking into the data structure and should use the data setters and getters exposed by the API, but well, everywhere there's pattern-matching against the jid record.


Also interesting, using uuids for all three parts of the jid:

Name ips average deviation median 99th %
master 5.02 M 199.21 ns ±16496.03% 125 ns 985 ns
this-PR 7.01 M 142.69 ns ±24749.32% 106 ns 169 ns
Name Memory usage
master 216 B
this-PR 192 B

@codecov-commenter
Copy link

codecov-commenter commented Feb 3, 2022

Codecov Report

Merging #7 (648f1c9) into master (bd28c4a) will decrease coverage by 1.15%.
The diff coverage is 76.92%.

@@            Coverage Diff             @@
##           master       #7      +/-   ##
==========================================
- Coverage   86.23%   85.08%   -1.16%     
==========================================
  Files           2        2              
  Lines         109      114       +5     
  Branches        7        7              
==========================================
+ Hits           94       97       +3     
- Misses         15       17       +2     
Impacted Files Coverage Δ
src/jid.erl 82.05% <76.92%> (-1.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd28c4a...648f1c9. Read the comment docs.

Remove fields that should actually never be used. The idea is that the
non-normalised parts MUST actually have never been used for comparison,
and are therefore not really needed. If only for printing and using them
in the `to` and `from` attributes of a stanza, clients SHOULD also
stringprep anyway, so the fact that the server might provide
non-normalised strings might be a problem for clients who're not
enforced to normalise them.

I've also been verifying how many other XMPP implementations tackle this
issue, and I've seen many other servers, and also a bunch of client
frameworks, simply capturing the parts and normalising them, and
building data structures that keep only their normalised pieces.
@NelsonVides NelsonVides changed the title Remove fields that should actually never be used Simplify the jid data structure Feb 3, 2022
Copy link
Member

@chrzaszcz chrzaszcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@chrzaszcz chrzaszcz merged commit a70d876 into master Apr 26, 2022
@NelsonVides NelsonVides deleted the reduce_jid_struct branch April 26, 2022 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants