db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1338167 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Date Mon, 14 May 2012 11:47:41 GMT
Author: kahatlen
Date: Mon May 14 11:47:40 2012
New Revision: 1338167

URL: http://svn.apache.org/viewvc?rev=1338167&view=rev
Log:
DERBY-5755: Minor cleanup of DataDictionaryImpl.getRoutineList()

Use java.util.Collections to create empty and single-element lists.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=1338167&r1=1338166&r2=1338167&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Mon May 14 11:47:40 2012
@@ -7761,12 +7761,15 @@ public final class	DataDictionaryImpl
 	public java.util.List getRoutineList(String schemaID, String routineName, char nameSpace)
 		throws StandardException {
 
-		java.util.List list = new  java.util.ArrayList();
-		
 		// Special in-memory table lookup for SYSFUN
 		if (schemaID.equals(SchemaDescriptor.SYSFUN_SCHEMA_UUID)
 				&& nameSpace == AliasInfo.ALIAS_NAME_SPACE_FUNCTION_AS_CHAR)
 		{
+            // We expect to find just a single function, since we currently
+            // don't support multiple routines with the same name, but use a
+            // list to support future extension.
+            List list = new ArrayList(1);
+
 			for (int f = 0; f < DataDictionaryImpl.SYSFUN_FUNCTIONS.length; f++)
 			{
 				String[] details = DataDictionaryImpl.SYSFUN_FUNCTIONS[f];
@@ -7819,10 +7822,9 @@ public final class	DataDictionaryImpl
 		}
 		
 		AliasDescriptor ad = getAliasDescriptor(schemaID, routineName, nameSpace);
-		if (ad != null) {
-			list.add(ad);
-		}
-		return list;
+        return ad == null ?
+                Collections.EMPTY_LIST :
+                Collections.singletonList(ad);
 	}
 
 	/** 



Mime
View raw message