jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
changeset 42444 628321b5a236
parent 39310 fed59f4021c8
child 43794 497288c158bf
equal deleted inserted replaced
42443:b9b966ca4a58 42444:628321b5a236
   329         Objects.requireNonNull(entry, "entry");
   329         Objects.requireNonNull(entry, "entry");
   330         int pos = -1;
   330         int pos = -1;
   331         ZipFileInputStream in = null;
   331         ZipFileInputStream in = null;
   332         synchronized (this) {
   332         synchronized (this) {
   333             ensureOpen();
   333             ensureOpen();
   334             if (!zc.isUTF8() && (entry.flag & EFS) != 0) {
   334             if (Objects.equals(lastEntryName, entry.name)) {
       
   335                 pos = lastEntryPos;
       
   336             } else if (!zc.isUTF8() && (entry.flag & EFS) != 0) {
   335                 pos = zsrc.getEntryPos(zc.getBytesUTF8(entry.name), false);
   337                 pos = zsrc.getEntryPos(zc.getBytesUTF8(entry.name), false);
   336             } else {
   338             } else {
   337                 pos = zsrc.getEntryPos(zc.getBytes(entry.name), false);
   339                 pos = zsrc.getEntryPos(zc.getBytes(entry.name), false);
   338             }
   340             }
   339             if (pos == -1) {
   341             if (pos == -1) {
   523         return StreamSupport.stream(Spliterators.spliterator(
   525         return StreamSupport.stream(Spliterators.spliterator(
   524                 new ZipEntryIterator(), size(),
   526                 new ZipEntryIterator(), size(),
   525                 Spliterator.ORDERED | Spliterator.DISTINCT |
   527                 Spliterator.ORDERED | Spliterator.DISTINCT |
   526                         Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
   528                         Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
   527     }
   529     }
       
   530 
       
   531     private String lastEntryName;
       
   532     private int lastEntryPos;
   528 
   533 
   529     /* Checks ensureOpen() before invoke this method */
   534     /* Checks ensureOpen() before invoke this method */
   530     private ZipEntry getZipEntry(String name, byte[] bname, int pos) {
   535     private ZipEntry getZipEntry(String name, byte[] bname, int pos) {
   531         byte[] cen = zsrc.cen;
   536         byte[] cen = zsrc.cen;
   532         int nlen = CENNAM(cen, pos);
   537         int nlen = CENNAM(cen, pos);
   561                 e.comment = zc.toStringUTF8(cen, start, clen);
   566                 e.comment = zc.toStringUTF8(cen, start, clen);
   562             } else {
   567             } else {
   563                 e.comment = zc.toString(cen, start, clen);
   568                 e.comment = zc.toString(cen, start, clen);
   564             }
   569             }
   565         }
   570         }
       
   571         lastEntryName = e.name;
       
   572         lastEntryPos = pos;
   566         return e;
   573         return e;
   567     }
   574     }
   568 
   575 
   569     /**
   576     /**
   570      * Returns the number of entries in the ZIP file.
   577      * Returns the number of entries in the ZIP file.