From daffed7bccaf3415a6b78867927af72a577ebe75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Alberto=20Can=CC=83as?= Date: Tue, 24 Jun 2014 21:48:33 -0600 Subject: [PATCH] Minimize Integer object construction Use Integer.valueOf(int) factory method instead of new Integer(int) constructor to take advantage of caching. This is especially useful when creating millions of ReceiveMessageRequests with the same options. --- src/main/clojure/cemerick/bandalore.clj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/clojure/cemerick/bandalore.clj b/src/main/clojure/cemerick/bandalore.clj index 39d9cc9..a4060ba 100644 --- a/src/main/clojure/cemerick/bandalore.clj +++ b/src/main/clojure/cemerick/bandalore.clj @@ -128,10 +128,10 @@ :or {limit 1 attributes #{}}}] (let [req (-> (ReceiveMessageRequest. queue-url) - (.withMaxNumberOfMessages (-> limit (min 10) (max 1) int Integer.)) + (.withMaxNumberOfMessages (-> limit (min 10) (max 1) int Integer/valueOf)) (.withAttributeNames attributes)) - req (if wait-time-seconds (.withWaitTimeSeconds req (Integer. (int wait-time-seconds))) req) - req (if visibility (.withVisibilityTimeout req (Integer. (int visibility))) req)] + req (if wait-time-seconds (.withWaitTimeSeconds req (Integer/valueOf (int wait-time-seconds))) req) + req (if visibility (.withVisibilityTimeout req (Integer/valueOf (int visibility))) req)] (->> (.receiveMessage client req) .getMessages (map (partial message-map queue-url)))))