From 6e38a25bcc15a6127574925d6675a17d9f24d0b4 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 05 Dec 2011 10:37:17 +0000
Subject: [PATCH] Minor optimization: avoid creating a new unmodifiable wrapper if the object is already unmodifiable.

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java
index 6d4b402..f420d4f 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2010 Sun Microsystems, Inc.
+ *      Portions copyright 2011 ForgeRock AS.
  */
 
 package org.forgerock.opendj.ldap;
@@ -614,7 +615,14 @@
   public static final Attribute unmodifiableAttribute(final Attribute attribute)
       throws NullPointerException
   {
-    return new UnmodifiableAttribute(attribute);
+    if (attribute instanceof UnmodifiableAttribute)
+    {
+      return attribute;
+    }
+    else
+    {
+      return new UnmodifiableAttribute(attribute);
+    }
   }
 
 

--
Gitblit v1.10.0