xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] Question about Text and how it stores data
- From: Michael Whapples <software AT mdw.onl>
- To: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] Question about Text and how it stores data
- Date: Wed, 20 Jan 2021 13:04:35 +0000
Thanks, I guess that makes sense. So should I take it that there is little chance it will be changed and if I want the speed optimisation then I should create my own fork?
I think why it looked odd to me is that it is not the simplest way to achieve the functionality. This is a case of optimising for memory use vs speed, in such a case I tend for the simplest solution unless evidence shows a need to perform the optimisation requiring something more complicated.
Regards
Michael Whapples
On 20/01/2021 11:40, Elliotte Rusty Harold wrote:
It's been a few years, but I'm pretty sure storing as UTF-8 instead of
a String was a deliberate decision to prioritize memory usage over
speed. Your priorities can differ of course.
On Wed, Jan 20, 2021 at 9:08 AM Michael Whapples <software AT mdw.onl> wrote:
Hello,
I was recently profiling an application which uses XOM with the
intention to improve performance. I noticed that in a section of code
where it does a reasonable amount of XML manipulation a significant
amount was down to calls to Text.setValue and Text.getValue. I could
appreciate setValue may need to do some validation checks, but I had
always thought getValue would have been a simple getter, the profiling
data told me otherwise.
I decided to examine the XOM source code to see exactlyt what is being
done in the Text class. This leads to the following question:
Why is data stored as a UTF8 byte array rather than as a String? Storing
as byte array requires conversion and associated memory allocation upon
every call to setValue and getValue. I see nothing in the source code
where the byte array is used directly. The only functionality I can see
related to it is that if the JVM does not support UTF8 encoding then
setValue will throw an exception, but I would have thought this check
would have been better placed in some initialising code so it is only
run once per JVM session.
Could this be changed in XOM or is there some reason I have overlooked
why it is done the way it is?
Regards
Michael Whapples
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
https://lists.ibiblio.org/mailman/listinfo/xom-interest
-
[XOM-interest] Question about Text and how it stores data,
Michael Whapples, 01/20/2021
-
Re: [XOM-interest] Question about Text and how it stores data,
Elliotte Rusty Harold, 01/20/2021
- Re: [XOM-interest] Question about Text and how it stores data, Michael Whapples, 01/20/2021
-
Re: [XOM-interest] Question about Text and how it stores data,
Michael Kay, 01/20/2021
- Re: [XOM-interest] Question about Text and how it stores data, Elliotte Rusty Harold, 01/20/2021
- Re: [XOM-interest] Question about Text and how it stores data, Michael Whapples, 01/20/2021
-
Re: [XOM-interest] Question about Text and how it stores data,
Elliotte Rusty Harold, 01/20/2021
Archive powered by MHonArc 2.6.24.