I was profiling some of our code which uses HL7, and I noticed that we had a 
large number of calls to java.util.Pattern#compile.

I tracked a number of them down to SegmentFinder#matches method. I would 
therefore suggest the patch below, which cuts down the number of 
Pattern#compile calls from 4 to 1.

The unit tests passes. I have written the code myself and would like to submit 
it under the same GPL/MPL license as the rest of the code.


Regards,
Niels Harremoës




Index: SegmentFinder.java
===================================================================
--- SegmentFinder.java   (revision 983)
+++ SegmentFinder.java (working copy)
@@ -157,8 +157,13 @@
         }
         return matches;
     }*/
-
+
     /**
+     * Patterns used for matching can only contain these characters
+     */
+    private static final Pattern VALID_PATTERN_PATTERN = 
Pattern.compile("[\\w\\*\\?]*");
+
+    /**
      * Tests whether the given name matches the given pattern.
      */
     private boolean matches(String pattern, String candidate) {
@@ -166,12 +171,12 @@
         if (pattern.equals(candidate)) {
             return true;
         }
-
-        if (!Pattern.matches("[\\w\\*\\?]*", pattern))
+
+        if (!VALID_PATTERN_PATTERN.matcher(pattern).matches())
             throw new IllegalArgumentException("The pattern " + pattern + " is 
not valid.  Only [\\w\\*\\?]* allowed.");

-        pattern = Pattern.compile("\\*").matcher(pattern).replaceAll(".*");
-        pattern = Pattern.compile("\\?").matcher(pattern).replaceAll(".");
+        pattern = pattern.replace("*",".*");
+        pattern = pattern.replace('?','.');

         return Pattern.matches(pattern, candidate);
     }



Fra: Ian Vowles [mailto:ian.vow...@health.qld.gov.au]
Sendt: 6. juni 2016 23:43
Til: HAPI Devel List
Emne: [HAPI-devel] RDS and RDE O01 messages

Is it possible to get a parser to recognise an implementation for RDS and RDE 
O01 messages?  My attempts so far have only returned a GenericMessage 
implementation. The HAPI structures have RDS_O13 and RDE_O11 but there doesn’t 
appear to be a mapping of RDE or RDS messages in model\v24\message 
2.4.properties (or v25).

Thanks
Ian Vowles
Systems Integration Team
eHealth Queensland,
Australia

********************************************************************************

This email, including any attachments sent with it, is confidential and for the 
sole use of the intended recipient(s). This confidentiality is not waived or 
lost, if you receive it and you are not the intended recipient(s), or if it is 
transmitted/received in error.

Any unauthorised use, alteration, disclosure, distribution or review of this 
email is strictly prohibited. The information contained in this email, 
including any attachment sent with it, may be subject to a statutory duty of 
confidentiality if it relates to health service matters.

If you are not the intended recipient(s), or if you have received this email in 
error, you are asked to immediately notify the sender by telephone collect on 
Australia +61 1800 198 175 or by return email. You should also delete this 
email, and any copies, from your computer system network and destroy any hard 
copies produced.

If not an intended recipient of this email, you must not copy, distribute or 
take any action(s) that relies on it; any form of disclosure, modification, 
distribution and/or publication of this email is also prohibited.

Although Queensland Health takes all reasonable steps to ensure this email does 
not contain malicious software, Queensland Health does not accept 
responsibility for the consequences if any person's computer inadvertently 
suffers any disruption to services, loss of information, harm or is infected 
with a virus, other malicious computer programme or code that may occur as a 
consequence of receiving this email.

Unless stated otherwise, this email represents only the views of the sender and 
not the views of the Queensland Government.

**********************************************************************************

________________________________


Denne e-mail indeholder fortrolig information. Hvis du ikke er den rette 
modtager af denne e-mail eller hvis du modtager den ved en fejltagelse, beder 
vi dig venligst informere afsender om fejlen ved at bruge svarfunktionen. 
Samtidig bedes du slette e-mailen med det samme uden at videresende eller 
kopiere den.
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to