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: Elliotte Rusty Harold <elharo AT ibiblio.org>
  • To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Question about Text and how it stores data
  • Date: Wed, 20 Jan 2021 11:40:12 +0000

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



--
Elliotte Rusty Harold
elharo AT ibiblio.org




Archive powered by MHonArc 2.6.24.

Top of Page