diff --git a/compiler2/Type.cc b/compiler2/Type.cc
index 7e2d8bdf1c8ed10573ee96a0bc19ec84abc3d1b8..e1c83c7415b81ef8b0dbbd68e043ba43eb2fff26 100644
--- a/compiler2/Type.cc
+++ b/compiler2/Type.cc
@@ -3509,6 +3509,14 @@ namespace Common {
       return false;
     }
     
+    // optimization: if it already has the encoding set, then the answer is true
+    for (size_t i = 0; i < coding_table.size(); ++i) {
+      if (coding_table[i]->built_in &&
+          coding_table[i]->built_in_coding == coding) {
+        return true;
+      }
+    }
+    
     switch (typetype) {
     case T_SEQ_T:
     case T_SEQ_A: