[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] FileListBlock remove un-necessary exception throw/catch
|
Folks,
This is a simple patch that takes a look at the bounds of an array
and returns the valid, but empty, value instead of explicitly throwing
an exception, catching it and then returning a valid but empty value.
This has a minor impact on performance and a huge impact on being
able to track down real exception errors since we aren't throwing/catching
spurious exceptions anymore.
(I'm on webmail so I've included and attached the patch since I don't
have a lot of faith in the web =;-)
ChangeLog
- Remove assumed throw/catch of an exception to be a regular occurance
and replace with explicit test and return for bounds access to the
particular array.
---- PATCH START ---
Index: index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java
===================================================================
RCS
file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/in
dex/impl/FileListBlock.java,v
retrieving revision 1.2
diff -u -r1.2 FileListBlock.java
--- index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java 4
Jul 2003 03:02:07 -0000 1.2
+++ index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java 2
Feb 2004 10:14:33 -0000
@@ -63,9 +63,12 @@
try {
String[] paths= getPaths();
int i= fileNum - field.getInt4(0);
+ if(i >= paths.length) { //fileNum was too large
+ return null;
+ }
resp= new IndexedFile(paths[i], fileNum);
} catch (Exception e) {
- //fileNum too big
+ //Cover ourselves in case something happens getting
the indexed file
}
return resp;
}
---- PATCH END ---
Index: index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java,v
retrieving revision 1.2
diff -u -r1.2 FileListBlock.java
--- index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java 4 Jul 2003 03:02:07 -0000 1.2
+++ index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java 2 Feb 2004 10:14:33 -0000
@@ -63,9 +63,12 @@
try {
String[] paths= getPaths();
int i= fileNum - field.getInt4(0);
+ if(i >= paths.length) { //fileNum was too large
+ return null;
+ }
resp= new IndexedFile(paths[i], fileNum);
} catch (Exception e) {
- //fileNum too big
+ //Cover ourselves in case something happens getting the indexed file
}
return resp;
}