< prev index next >

src/java.base/share/classes/com/sun/java/util/jar/pack/ConstantPool.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


1349             }
1350             if (e == null)  return -1;
1351             int tag = e.tag;
1352             Index ix = indexByTag[tag];
1353             if (ix == null)  return -1;
1354             int idx = ix.findIndexOf(e);
1355             if (idx >= 0)
1356                 idx += untypedFirstIndexByTag[tag];
1357             return idx;
1358         }
1359 
1360         public void initIndexByTag(byte tag, Index ix) {
1361             assert(indexByTag[tag] == null);  // do not init twice
1362             Entry[] cpMap = ix.cpMap;
1363             for (int i = 0; i < cpMap.length; i++) {
1364                 // It must be a homogeneous Entry set.
1365                 assert(cpMap[i].tag == tag);
1366             }
1367             if (tag == CONSTANT_Utf8) {
1368                 // Special case:  First Utf8 must always be empty string.
1369                 assert(cpMap.length == 0 || cpMap[0].stringValue().equals(""));
1370             }
1371             indexByTag[tag] = ix;
1372             // decache indexes derived from this one:
1373             untypedFirstIndexByTag = null;
1374             indexByTagGroup = null;
1375             if (indexByTagAndClass != null)
1376                 indexByTagAndClass[tag] = null;
1377         }
1378 
1379         /** Index of all CP entries of a given tag. */
1380         public Index getIndexByTag(byte tag) {
1381             if (tag >= CONSTANT_GroupFirst)
1382                 return getIndexByTagGroup(tag);
1383             Index ix = indexByTag[tag];
1384             if (ix == null) {
1385                 // Make an empty one by default.
1386                 ix = new Index(tagName(tag), new Entry[0]);
1387                 indexByTag[tag] = ix;
1388             }
1389             return ix;




1349             }
1350             if (e == null)  return -1;
1351             int tag = e.tag;
1352             Index ix = indexByTag[tag];
1353             if (ix == null)  return -1;
1354             int idx = ix.findIndexOf(e);
1355             if (idx >= 0)
1356                 idx += untypedFirstIndexByTag[tag];
1357             return idx;
1358         }
1359 
1360         public void initIndexByTag(byte tag, Index ix) {
1361             assert(indexByTag[tag] == null);  // do not init twice
1362             Entry[] cpMap = ix.cpMap;
1363             for (int i = 0; i < cpMap.length; i++) {
1364                 // It must be a homogeneous Entry set.
1365                 assert(cpMap[i].tag == tag);
1366             }
1367             if (tag == CONSTANT_Utf8) {
1368                 // Special case:  First Utf8 must always be empty string.
1369                 assert(cpMap.length == 0 || cpMap[0].stringValue().isEmpty());
1370             }
1371             indexByTag[tag] = ix;
1372             // decache indexes derived from this one:
1373             untypedFirstIndexByTag = null;
1374             indexByTagGroup = null;
1375             if (indexByTagAndClass != null)
1376                 indexByTagAndClass[tag] = null;
1377         }
1378 
1379         /** Index of all CP entries of a given tag. */
1380         public Index getIndexByTag(byte tag) {
1381             if (tag >= CONSTANT_GroupFirst)
1382                 return getIndexByTagGroup(tag);
1383             Index ix = indexByTag[tag];
1384             if (ix == null) {
1385                 // Make an empty one by default.
1386                 ix = new Index(tagName(tag), new Entry[0]);
1387                 indexByTag[tag] = ix;
1388             }
1389             return ix;


< prev index next >