James Mime4j
  1. James Mime4j
  2. MIME4J-96

Field.parse() should defer parsing until the parsed value is actually requested

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.5
    • Fix Version/s: 0.6
    • Component/s: None
    • Labels:
      None

      Description

      Currently the MessageBuilder invokes Field.parse() for every header field of a message. Benchmark tests have shown that this has a significant impact on performance.

      For example, DateTimeField parses the Date header into a java.util.Date object regardless if this value is ever needed or not.

      1. DateTimeField.java
        3 kB
        Markus Wiederkehr

        Activity

        Hide
        Robert Burrell Donkin added a comment -

        Closing all issues fixed previously, after a brief review of each.

        Show
        Robert Burrell Donkin added a comment - Closing all issues fixed previously, after a brief review of each.
        Hide
        Markus Wiederkehr added a comment -

        Patch applied. The test now runs under 22 seconds on my machine.

        Show
        Markus Wiederkehr added a comment - Patch applied. The test now runs under 22 seconds on my machine.
        Hide
        Markus Wiederkehr added a comment -

        Attached a new version of DateTimeField that does not parse the Date header until the value is actually requested.

        This change alone reduces the runtime of LongMultipartReadBench #3 from 47 seconds to 35 seconds on my machine.

        The other Field subclasses could be refactored in a similar fashion.

        If this is acceptable I would also suggest that FieldParser gets renamed in FieldFactory to better describe what it actually is..

        Show
        Markus Wiederkehr added a comment - Attached a new version of DateTimeField that does not parse the Date header until the value is actually requested. This change alone reduces the runtime of LongMultipartReadBench #3 from 47 seconds to 35 seconds on my machine. The other Field subclasses could be refactored in a similar fashion. If this is acceptable I would also suggest that FieldParser gets renamed in FieldFactory to better describe what it actually is..

          People

          • Assignee:
            Markus Wiederkehr
            Reporter:
            Markus Wiederkehr
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development