Uploaded image for project: 'James Mime4j'
  1. James Mime4j
  2. MIME4J-283

DecoderUtil performance fix

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • master, 0.8.2
    • 0.8.3
    • parser (core)
    • None

    Description

      DecoderUtil currently uses the following regex pattern for rfc2047-encoded words: 

      "(.*?)=\\?(.+?)\\?(\\w)\\?(.*?)\\?="
      

      First capturing group (.*?) is a very expensive regular expression causing next pattern node evaluation on every input character. Because of this decoding of 4 KB input (To: field with 40-80 recipients) takes up to 200ms on modern CPUs.

      At the same time, this capturing group used only to store separator text between encoded words. Proposed patch reuses existing tailIndex for separator text extraction and same input decoding now takes only 1-2ms.

      Attachments

        1. patch
          2 kB
          Dmitry Potapov

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hirthwork Dmitry Potapov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m