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.
This commit is contained in:
Daniel Alberto Cañas 2014-06-24 21:48:33 -06:00
parent ce8c02bdc4
commit daffed7bcc

View file

@ -128,10 +128,10 @@
:or {limit 1 :or {limit 1
attributes #{}}}] attributes #{}}}]
(let [req (-> (ReceiveMessageRequest. queue-url) (let [req (-> (ReceiveMessageRequest. queue-url)
(.withMaxNumberOfMessages (-> limit (min 10) (max 1) int Integer.)) (.withMaxNumberOfMessages (-> limit (min 10) (max 1) int Integer/valueOf))
(.withAttributeNames attributes)) (.withAttributeNames attributes))
req (if wait-time-seconds (.withWaitTimeSeconds req (Integer. (int wait-time-seconds))) req) req (if wait-time-seconds (.withWaitTimeSeconds req (Integer/valueOf (int wait-time-seconds))) req)
req (if visibility (.withVisibilityTimeout req (Integer. (int visibility))) req)] req (if visibility (.withVisibilityTimeout req (Integer/valueOf (int visibility))) req)]
(->> (.receiveMessage client req) (->> (.receiveMessage client req)
.getMessages .getMessages
(map (partial message-map queue-url))))) (map (partial message-map queue-url)))))