JID and BareJID classes are simple, however are used very ofter during processing. As I checked creation of JID and BareJID is not as fast as it should.
It looks that it is caused by code responsible for parsing string to JID (lookup for / and @ as well as splitting strings).
We need to find better way to parse JID.
It may also be a good idea to cache JID instance of stanza returned by to and from as now they are constructed every time.
Andrzej Wójcik (Tigase) commented 8 years ago
After checking performance of parsing JID and BareJID and comparing with alternative methods looks like we are using the fastest one I've found.
Due to that I added caching of JID and BareJID instances in Stanza instance to reduce number of instantiations of JID and BareJID during processing of incoming packets. This reduced processing time and improved performance of library.
+Note:+ From now on it is required to modify from and to of stanza instance always using stanza properties instead of direct manipulation of attributes of stanza element. Direct manipulation of attributes may lead to invalid values being returned by stanza instance! This information was added to library documentation of Stanza class.
JID and BareJID classes are simple, however are used very ofter during processing. As I checked creation of JID and BareJID is not as fast as it should.
It looks that it is caused by code responsible for parsing string to JID (lookup for
/
and@
as well as splitting strings).We need to find better way to parse JID.
It may also be a good idea to cache JID instance of stanza returned by
to
andfrom
as now they are constructed every time.