You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2008/01/09 00:55:22 UTC
svn commit: r610234 - in
/myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component:
UIXCollection.java UIXComponentBase.java
Author: gcrawford
Date: Tue Jan 8 15:55:14 2008
New Revision: 610234
URL: http://svn.apache.org/viewvc?rev=610234&view=rev
Log:
TRINIDAD-887 perf: USE CORRECTLY SIZED STRINGBUILDERS IN GETCLIENTID
Use correctly sized stringBuilder to reduce excess memory allocation
Modified:
myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
Modified: myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java?rev=610234&r1=610233&r2=610234&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java Tue Jan 8 15:55:14 2008
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -557,9 +557,9 @@
@Deprecated
public String getCurrencyString()
{
- return getClientRowKey();
+ return getClientRowKey();
}
-
+
/**
* @deprecated use setClientRowKey
* @see #setClientRowKey
@@ -669,7 +669,9 @@
String key = getClientRowKey();
if (key != null)
{
- id += NamingContainer.SEPARATOR_CHAR + key;
+ StringBuilder bld = new StringBuilder(id.length() + 1 + key.length());
+ bld.append(id).append(NamingContainer.SEPARATOR_CHAR).append(key);
+ id = bld.toString();
}
return id;
@@ -816,11 +818,11 @@
if ((singleFacetState == null) ||
(singleFacetState == Transient.TRUE))
continue;
-
+
// Don't bother allocating anything until we have some non-null
// and non-transient facet state
if (facetStateIsEmpty)
- {
+ {
facetStateIsEmpty = false;
facetState = new Object[facetCount * 2];
}
@@ -831,7 +833,7 @@
facetState[base + 1] = singleFacetState;
i++;
}
-
+
// OK, we had something: allocate the state array to three
// entries, and insert the facet state at position 2
if (!facetStateIsEmpty)
@@ -885,7 +887,7 @@
// Just a transient component - return
if ((stampState == Transient.TRUE) || (stampState == null))
return;
-
+
// If this isn't an Object array, then it's a component with state
// of its own, but no child/facet state - so restore and be done
if (!(stampState instanceof Object[]))
@@ -907,7 +909,7 @@
if (stateSize >= 3)
{
Object[] facetStateArray = (Object[]) state[2];
- // This had better be non-null, otherwise we never
+ // This had better be non-null, otherwise we never
// should have allocated a three-element array!
assert(facetStateArray != null);
@@ -919,7 +921,7 @@
restoreStampState(context, stamp.getFacet(facetName), facetState);
}
}
-
+
// If there's any child state, restore it
if (stateSize >= 2)
{
@@ -978,7 +980,7 @@
/**
* Gets the ClientRowKeyManager that is used to handle the
- * {@link #getClientRowKey} and
+ * {@link #getClientRowKey} and
* {@link #setClientRowKey} methods.
* If the manager does not already exist a new one is created.
* In order to create your own manager, your Renderer (for this component)
@@ -989,7 +991,7 @@
{
// this method must be public, because specific renderers
// need access to the ClientRowKeyManager so that they might prune it.
-
+
InternalState iState = _getInternalState(true);
if (iState._clientKeyMgr == null)
{
@@ -1003,7 +1005,7 @@
}
public boolean invokeOnComponent(FacesContext context,
- String clientId,
+ String clientId,
ContextCallback callback)
throws FacesException
{
@@ -1036,7 +1038,7 @@
try
{
setCurrencyString(currencyString);
- return super.invokeOnComponent(context, clientId, callback);
+ return super.invokeOnComponent(context, clientId, callback);
}
finally
{
@@ -1044,7 +1046,7 @@
setRowKey(oldRowKey);
}
}
-
+
return false;
}
@@ -1177,10 +1179,10 @@
iState._model = createCollectionModel(iState._model, value);
}
}
-
+
//
// Returns true if this is the first request to invokeOnComponent()
- //
+ //
static private boolean _getAndMarkFirstInvokeForRequest(
FacesContext context, String clientId)
{
@@ -1238,7 +1240,7 @@
{
// Never read and created by _getStampState
//InternalState iState = _getInternalState(true);
-
+
StampState stampState = _getStampState();
FacesContext context = getFacesContext();
Object currencyObj = getRowKey();
@@ -1366,7 +1368,7 @@
{
if (_isOptimizedKey(clientRowKey))
return clientRowKey;
-
+
ValueMap<Object,String> currencyCache = _currencyCache;
Object rowkey = currencyCache.getKey(clientRowKey);
return rowkey;
@@ -1386,7 +1388,7 @@
if (key == null)
{
// we don't have a string-key, so create a new one.
-
+
// first check to see if the rowkey itself can be used as the string-key:
if (rowKey instanceof String)
{
Modified: myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java?rev=610234&r1=610233&r2=610234&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java Tue Jan 8 15:55:14 2008
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -66,7 +66,7 @@
* <li>Use of FacesBean for better and easier state saving</li>
* <li>Support of the LifecycleRenderer class for greater Renderer
* control over the lifecycle</li>
- * <li>Built-in support for both the "partialTriggers" attribute
+ * <li>Built-in support for both the "partialTriggers" attribute
* (declarative support for being a PPR target) and for triggering
* such components (for being a the source of a PPR-causing event).</li>
* </ul>
@@ -230,7 +230,7 @@
}
@Override
- public void setValueExpression(String name,
+ public void setValueExpression(String name,
ValueExpression expression)
{
if (name == null)
@@ -317,9 +317,10 @@
{
if (containerComponent instanceof NamingContainer)
{
- clientId = (containerComponent.getContainerClientId(context) +
- NamingContainer.SEPARATOR_CHAR +
- clientId);
+ String contClientId = containerComponent.getContainerClientId(context);
+ StringBuilder bld = new StringBuilder(contClientId.length() + 1 + clientId.length());
+ bld.append(contClientId).append(NamingContainer.SEPARATOR_CHAR).append(clientId);
+ clientId = bld.toString();
break;
}
@@ -625,7 +626,7 @@
{
childrenAndFacets.add(facet);
}
-
+
for(UIComponent child : _children)
{
childrenAndFacets.add(child);
@@ -658,9 +659,9 @@
adfContext.partialUpdateNotify(component);
}
- Iterator<FacesListener> iter =
+ Iterator<FacesListener> iter =
(Iterator<FacesListener>)getFacesBean().entries(_LISTENERS_KEY);
-
+
while (iter.hasNext())
{
FacesListener listener = iter.next();
@@ -1379,9 +1380,9 @@
private transient Renderer _cachedRenderer = _UNDEFINED_RENDERER;
private transient LifecycleRenderer _cachedLifecycleRenderer =
_UNDEFINED_LIFECYCLE_RENDERER;
-
+
// -= Simon Lessard =-
- // FIXME: _initialStateMarked is never read
+ // FIXME: _initialStateMarked is never read
// So commented out, is that ok? If so, this attribute should be deleted
//private transient boolean _initialStateMarked;
@@ -1438,7 +1439,7 @@
static private class ExtendedRendererImpl extends ExtendedRenderer
{
}
-
+
private static class EmptyIterator<T> implements Iterator<T>
{
public boolean hasNext()
@@ -1455,7 +1456,7 @@
{
throw new UnsupportedOperationException();
}
-
+
}
static private final LifecycleRenderer _UNDEFINED_LIFECYCLE_RENDERER =