Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Question about Text and how it stores data

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • 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:29:38 +0000

Interesting about the Java9 compact strings. We recently moved our application from Java8 to Java15, and I wasn't aware of the compact strings feature.


Michael Whapples

On 20/01/2021 11:39, Michael Kay wrote:
Interesting.

I imagine it was done for space saving, though that's largely redundant with
the changes to the String implementation in Java 9.

I'm interested because we're moving to use of byte arrays (one, two, or three
bytes per character) in the Saxon tree implementation, but that's to achieve
unicode codepoint addressing for XPath operations like substring(), where
UTF-8 doesn't help at all.

Michael Kay
Saxonica

On 20 Jan 2021, at 09:01, 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 mailing list
XOM-interest AT lists.ibiblio.org
https://lists.ibiblio.org/mailman/listinfo/xom-interest




Archive powered by MHonArc 2.6.24.

Top of Page