Corrected part of fix Bug 475436 - Investigate performance issue in
APIerror/warning for large workspace. 

Change-Id: If007bbf18d0514d06aeecaf3e8a6e657ef0c86a6
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ResourceApiTypeRoot.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ResourceApiTypeRoot.java
index 1777708..c53e7ec 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ResourceApiTypeRoot.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ResourceApiTypeRoot.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -32,6 +32,12 @@
 	 */
 	private IFile fFile;
 
+	// when class file is changed, the object is changed too
+	// can store the contents in the class field for optimisation.
+	byte[] fContents = null;
+
+	private long localTimeStamp ;
+
 	/**
 	 * Constructs an {@link IApiTypeRoot} on the underlying file.
 	 *
@@ -46,9 +52,14 @@
 
 	@Override
 	public byte[] getContents() throws CoreException {
+		if (fContents != null && fFile.getLocalTimeStamp() == localTimeStamp) {
+			return fContents;
+		}
+		localTimeStamp = fFile.getLocalTimeStamp();
 		InputStream stream = fFile.getContents(true);
 		try {
-			return Util.getInputStreamAsByteArray(stream, -1);
+			fContents = Util.getInputStreamAsByteArray(stream, -1);
+			return fContents;
 		} catch (IOException ioe) {
 			abort("Unable to read class file: " + getTypeName(), ioe); //$NON-NLS-1$
 			return null;