licensing update to APSL 2.0
[nestedvm.git] / src / org / ibex / nestedvm / util / InodeCache.java
index 99d2a98..02913de 100644 (file)
@@ -1,6 +1,8 @@
-package org.ibex.nestedvm.util;
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
 
-import java.util.Arrays;
+package org.ibex.nestedvm.util;
 
 // Based on the various org.xwt.util.* classes by Adam Megacz
 
@@ -37,12 +39,14 @@ public class InodeCache {
         clear();
     }
     
+    private static void fill(Object[] a,Object o) { for(int i=0;i<a.length;i++) a[i] = o; }
+    private static void fill(short[] a, short s)  { for(int i=0;i<a.length;i++) a[i] = s; }
     public final void clear() {
         size = usedSlots = 0;
         mru = lru = -1;
-        Arrays.fill(keys,null);
-        Arrays.fill(inodes,SHORT_NULL);
-        Arrays.fill(reverse,SHORT_NULL);
+        fill(keys,null);
+        fill(inodes,SHORT_NULL);
+        fill(reverse,SHORT_NULL);
     }
     
     public final short get(Object key) {
@@ -56,7 +60,7 @@ public class InodeCache {
         
         while((k = keys[dest]) != null) {
             if(k == PLACEHOLDER) {
-                   if(placeholder == -1) placeholder = dest;
+                if(placeholder == -1) placeholder = dest;
             } else if(k.equals(key)) {
                 short inode = inodes[dest];
                 if(dest == mru) return inode;
@@ -130,8 +134,8 @@ public class InodeCache {
         reverse[dest] = (short) slot;
         inodes[slot] = (short) inode;
         if(mru != -1) {
-                   prev[slot] = mru;
-                   next[mru] = (short) slot;
+            prev[slot] = mru;
+            next[mru] = (short) slot;
         }
         mru = (short) slot;
         return (short) inode;
@@ -152,7 +156,7 @@ public class InodeCache {
         return null;
     }
     
-    private void dump() {
+    /*private void dump() {
         System.err.println("Size " + size);
         System.err.println("UsedSlots " + usedSlots);
         System.err.println("MRU " + mru);
@@ -184,20 +188,20 @@ public class InodeCache {
         String s;
         boolean good = false;
         try {
-                   while((s = br.readLine()) != null) {
+            while((s = br.readLine()) != null) {
                 if(s.charAt(0) == '#') {
                     short n = Short.parseShort(s.substring(1));
-                           System.err.println("" + n + " -> " + c.reverse(n));
+                        System.err.println("" + n + " -> " + c.reverse(n));
                 } else {
-                           //System.err.println("Adding " + s);
-                               short n = c.get(s);
-                               System.err.println("Added " + s + " -> " + n);
-                               //c.dump();
+                    //System.err.println("Adding " + s);
+                    short n = c.get(s);
+                    System.err.println("Added " + s + " -> " + n);
+                    //c.dump();
                 }
             }
             good = true;
         } finally {
             if(!good) c.stats();
         }
-    }
+    }*/
 }