Skip to Content.
Sympa Menu

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

xom-interest AT

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Michael Whapples <software AT>
  • To: xom-interest AT
  • Subject: [XOM-interest] Question about Text and how it stores data
  • Date: Wed, 20 Jan 2021 09:01:02 +0000


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?


Michael Whapples

Archive powered by MHonArc 2.6.24.

Top of Page