1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 01:35:39 +02:00

cosmetics: generics, loops

This commit is contained in:
Andrew Gvozdev 2010-01-28 21:23:44 +00:00
parent a62de2fbe6
commit 402838f2a6

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Intel Corporation and others. * Copyright (c) 2007, 2010 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.settings.model; package org.eclipse.cdt.internal.core.settings.model;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.settings.model.extension.CDataObject; import org.eclipse.cdt.core.settings.model.extension.CDataObject;
@ -21,7 +20,7 @@ public class ProxyProvider implements IProxyProvider {
private ICDataScope fScope; private ICDataScope fScope;
private IProxyFactory fFactory; private IProxyFactory fFactory;
private boolean fProxiesCached; private boolean fProxiesCached;
public ProxyProvider(ICDataScope scope, IProxyCache cache, IProxyFactory factory){ public ProxyProvider(ICDataScope scope, IProxyCache cache, IProxyFactory factory){
fScope = scope; fScope = scope;
fCache = cache; fCache = cache;
@ -35,7 +34,7 @@ public class ProxyProvider implements IProxyProvider {
} }
return fCache.getCachedProxies(); return fCache.getCachedProxies();
} }
/* /*
private void clearInvalidCachedProxies(){ private void clearInvalidCachedProxies(){
CDataProxy proxies[] = fCache.getCachedProxies(); CDataProxy proxies[] = fCache.getCachedProxies();
for(int i = 0; i < proxies.length; i++){ for(int i = 0; i < proxies.length; i++){
@ -52,13 +51,12 @@ public class ProxyProvider implements IProxyProvider {
} }
return fCache.getCachedProxy(id); return fCache.getCachedProxy(id);
} }
protected void fillCache(){ protected void fillCache(){
Map map = fCache.getCachedProxiesMap(); Map<String, CDataProxy> map = fCache.getCachedProxiesMap();
CDataObject datas[] =fScope.getChildren(); CDataObject datas[] =fScope.getChildren();
for(int i = 0; i < datas.length; i++){ for (CDataObject data : datas) {
CDataObject data = datas[i];
CDataProxy proxy = fCache.getCachedProxy(data.getId()); CDataProxy proxy = fCache.getCachedProxy(data.getId());
if(proxy == null || proxy.getType() != data.getType()){ if(proxy == null || proxy.getType() != data.getType()){
proxy = fFactory.createProxy(data); proxy = fFactory.createProxy(data);
@ -70,14 +68,14 @@ public class ProxyProvider implements IProxyProvider {
map.remove(data.getId()); map.remove(data.getId());
} }
} }
if(!map.isEmpty()){ if(!map.isEmpty()){
for(Iterator iter = map.values().iterator(); iter.hasNext();){ for (CDataProxy proxy : map.values()) {
fCache.removeCachedProxy((CDataProxy)iter.next()); fCache.removeCachedProxy(proxy);
} }
} }
} }
public CDataProxy getProxy(CDataObject data) { public CDataProxy getProxy(CDataObject data) {
if(!fProxiesCached || !fScope.isStatic()){ if(!fProxiesCached || !fScope.isStatic()){
fillCache(); fillCache();
@ -105,12 +103,11 @@ public class ProxyProvider implements IProxyProvider {
if(proxies.length > 0){ if(proxies.length > 0){
CDataProxy[] tmp = new CDataProxy[proxies.length]; CDataProxy[] tmp = new CDataProxy[proxies.length];
int num = 0; int num = 0;
for(int i = 0; i < proxies.length; i++){ for (CDataProxy proxy : proxies) {
CDataProxy proxy = proxies[i];
if((proxy.getType() & kind) == proxy.getType()) if((proxy.getType() & kind) == proxy.getType())
tmp[num++] = proxy; tmp[num++] = proxy;
} }
if(num != proxies.length){ if(num != proxies.length){
proxies = new CDataProxy[num]; proxies = new CDataProxy[num];
System.arraycopy(tmp, 0, proxies, 0, num); System.arraycopy(tmp, 0, proxies, 0, num);
@ -129,10 +126,10 @@ public class ProxyProvider implements IProxyProvider {
public void invalidateCache() { public void invalidateCache() {
fProxiesCached = false; fProxiesCached = false;
CDataProxy[] proxies = fCache.getCachedProxies(); CDataProxy[] proxies = fCache.getCachedProxies();
for(int i = 0; i < proxies.length; i++){ for (CDataProxy proxy : proxies) {
proxies[i].doClearData(); proxy.doClearData();
} }
} }
} }