Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-10 07:51:14 +0000
committerMarkus Schorn2008-04-10 07:51:14 +0000
commit68db07fc5d32460212ae0ef6e2b254cb27d97ff4 (patch)
tree7fa2f0256f84eee213de6b7e60c95db2fd7adf96 /core/org.eclipse.cdt.core
parent94a11113b458a466cf7c358fb5d61dc81b55a1b5 (diff)
downloadorg.eclipse.cdt-68db07fc5d32460212ae0ef6e2b254cb27d97ff4.tar.gz
org.eclipse.cdt-68db07fc5d32460212ae0ef6e2b254cb27d97ff4.tar.xz
org.eclipse.cdt-68db07fc5d32460212ae0ef6e2b254cb27d97ff4.zip
Extracted a constant.
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java41
1 files changed, 20 insertions, 21 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
index 6ccaf050417..a9e1021de88 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java
@@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArraySet;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
@@ -35,6 +36,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
*
*/
public class SemanticUtil {
+ private static final char[] OPERATOR_CHARS = Keywords.OPERATOR.toCharArray();
/**
* Cache of overloadable operator names for fast lookup. Used by isConversionOperator.
*/
@@ -103,8 +105,9 @@ public class SemanticUtil {
IBinding binding= base.getBaseClass();
if(binding instanceof ICPPClassType && !(binding instanceof IProblemBinding)) {
ICPPClassType ct= (ICPPClassType) binding;
- if(!done.containsKey(ct))
+ if(!done.containsKey(ct)) {
next.put(ct);
+ }
}
}
}
@@ -122,16 +125,12 @@ public class SemanticUtil {
private static final boolean isConversionOperator(ICPPMethod method) {
boolean result= false;
if(!method.isImplicit()) {
- char[] name= method.getNameCharArray();
- char[] expected= Keywords.OPERATOR.toCharArray();
- if(name.length > expected.length + 1) {
- for(int i=0; i<expected.length; i++) {
- if(name[i] != expected[i])
- return false;
+ final char[] name= method.getNameCharArray();
+ if (name.length > OPERATOR_CHARS.length + 1 &&
+ CharArrayUtils.equals(name, 0, OPERATOR_CHARS.length, OPERATOR_CHARS)) {
+ if(name[OPERATOR_CHARS.length]==' ') {
+ result= !cas.containsKey(name, OPERATOR_CHARS.length+1, name.length - (OPERATOR_CHARS.length+1));
}
- if(name[expected.length]!=' ')
- return false;
- result= !cas.containsKey(name, expected.length+1, name.length - (expected.length+1));
}
}
return result;
@@ -159,20 +158,20 @@ public class SemanticUtil {
static IType getUltimateType(IType type, IType[] lastPointerType, boolean stopAtPointerToMember) {
try {
while( true ){
- if( type instanceof ITypedef )
+ if( type instanceof ITypedef ) {
type= ((ITypedef)type).getType();
- else if( type instanceof IQualifierType )
- type= ((IQualifierType)type).getType();
- else if( stopAtPointerToMember && type instanceof ICPPPointerToMemberType )
+ } else if( type instanceof IQualifierType ) {
+ type= ((IQualifierType)type).getType();
+ } else if( stopAtPointerToMember && type instanceof ICPPPointerToMemberType )
return type;
else if( type instanceof IPointerType ) {
if(lastPointerType!=null) {
lastPointerType[0]= type;
}
type= ((IPointerType) type).getType();
- } else if( type instanceof ICPPReferenceType )
+ } else if( type instanceof ICPPReferenceType ) {
type= ((ICPPReferenceType)type).getType();
- else
+ } else
return type;
}
@@ -190,13 +189,13 @@ public class SemanticUtil {
public static IType getUltimateTypeUptoPointers(IType type){
try {
while( true ){
- if( type instanceof ITypedef )
- type = ((ITypedef)type).getType();
- else if( type instanceof IQualifierType )
+ if( type instanceof ITypedef ) {
+ type = ((ITypedef)type).getType();
+ } else if( type instanceof IQualifierType ) {
type = ((IQualifierType)type).getType();
- else if( type instanceof ICPPReferenceType )
+ } else if( type instanceof ICPPReferenceType ) {
type = ((ICPPReferenceType)type).getType();
- else
+ } else
return type;
}
} catch ( DOMException e ) {

Back to the top