Skip to content

Commit

Permalink
Rename LazyByteData to LazyMemorySegment
Browse files Browse the repository at this point in the history
  • Loading branch information
xxDark committed Apr 11, 2024
1 parent c30bbca commit 905d881
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import software.coley.lljzip.format.compression.Decompressor;
import software.coley.lljzip.format.compression.ZipCompressions;
import software.coley.lljzip.util.MemorySegmentUtil;
import software.coley.lljzip.util.lazy.LazyByteData;
import software.coley.lljzip.util.lazy.LazyMemorySegment;
import software.coley.lljzip.util.lazy.LazyInt;
import software.coley.lljzip.util.lazy.LazyLong;

Expand All @@ -28,8 +28,8 @@ public abstract class AbstractZipFileHeader implements ZipPart, ZipRead {
protected LazyLong uncompressedSize;
protected LazyInt fileNameLength;
protected LazyInt extraFieldLength;
protected LazyByteData fileName;
protected LazyByteData extraField;
protected LazyMemorySegment fileName;
protected LazyMemorySegment extraField;

// Offset into the data this part is read from
protected transient long offset = -1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package software.coley.lljzip.format.model;

import software.coley.lljzip.util.lazy.LazyByteData;
import software.coley.lljzip.util.lazy.LazyMemorySegment;
import software.coley.lljzip.util.lazy.LazyInt;
import software.coley.lljzip.util.lazy.LazyLong;

Expand Down Expand Up @@ -44,19 +44,19 @@ public AdaptingLocalFileHeader(@Nonnull ZipFile archive, @Nonnull ZipEntry entry
lastModFileTime = new LazyInt(() -> 0);
lastModFileDate = new LazyInt(() -> 0);
fileNameLength = new LazyInt(entryName::length);
fileName = new LazyByteData(() -> MemorySegment.ofArray(entryName.getBytes()));
fileName = new LazyMemorySegment(() -> MemorySegment.ofArray(entryName.getBytes()));
fileDataLength = new LazyLong(() -> entryData.length);
fileData = new LazyByteData(() -> MemorySegment.ofArray(entryData));
fileData = new LazyMemorySegment(() -> MemorySegment.ofArray(entryData));
compressionMethod = new LazyInt(() -> 0);
uncompressedSize = new LazyLong(() -> entryData.length);
compressedSize = new LazyLong(() -> entryData.length);
crc32 = new LazyInt(() -> (int) entry.getCrc());
if (extra != null) {
extraFieldLength = new LazyInt(() -> extra.length);
extraField = new LazyByteData(() -> MemorySegment.ofArray(extra));
extraField = new LazyMemorySegment(() -> MemorySegment.ofArray(extra));
} else {
extraFieldLength = new LazyInt(() -> 0);
extraField = new LazyByteData(() -> MemorySegment.ofArray(new byte[0]));
extraField = new LazyMemorySegment(() -> MemorySegment.ofArray(new byte[0]));
}
data = MemorySegment.ofArray(new byte[0]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package software.coley.lljzip.format.model;

import software.coley.lljzip.util.MemorySegmentUtil;
import software.coley.lljzip.util.lazy.LazyByteData;
import software.coley.lljzip.util.lazy.LazyMemorySegment;
import software.coley.lljzip.util.lazy.LazyInt;
import software.coley.lljzip.util.lazy.LazyLong;

Expand Down Expand Up @@ -43,7 +43,7 @@ public class CentralDirectoryFileHeader extends AbstractZipFileHeader {
// CentralDirectoryFileHeader spec (plus common elements between this and local file)
private LazyInt versionMadeBy;
private LazyInt fileCommentLength;
private LazyByteData fileComment;
private LazyMemorySegment fileComment;
private LazyInt diskNumberStart;
private LazyInt internalFileAttributes;
private LazyInt externalFileAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import software.coley.lljzip.format.compression.Decompressor;
import software.coley.lljzip.format.read.ZipReader;
import software.coley.lljzip.util.MemorySegmentUtil;
import software.coley.lljzip.util.lazy.LazyByteData;
import software.coley.lljzip.util.lazy.LazyMemorySegment;
import software.coley.lljzip.util.lazy.LazyInt;
import software.coley.lljzip.util.lazy.LazyLong;

Expand Down Expand Up @@ -42,7 +42,7 @@ public class LocalFileHeader extends AbstractZipFileHeader {
protected transient CentralDirectoryFileHeader linkedDirectoryFileHeader;

// LocalFileHeader spec (plus common elements between this and central file)
protected LazyByteData fileData;
protected LazyMemorySegment fileData;

// Caches
protected transient LazyLong fileDataLength;
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/software/coley/lljzip/util/MemorySegmentUtil.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package software.coley.lljzip.util;

import software.coley.lljzip.format.model.ZipPart;
import software.coley.lljzip.util.lazy.LazyByteData;
import software.coley.lljzip.util.lazy.LazyMemorySegment;
import software.coley.lljzip.util.lazy.LazyInt;
import software.coley.lljzip.util.lazy.LazyLong;

Expand Down Expand Up @@ -399,8 +399,8 @@ public static LazyLong readLazyMaskedLongQuad(MemorySegment data, long headerOff
*
* @return Lazily populated slice.
*/
public static LazyByteData readLazySlice(MemorySegment data, long headerOffset, LazyInt localOffset, LazyInt length) {
return new LazyByteData(() -> {
public static LazyMemorySegment readLazySlice(MemorySegment data, long headerOffset, LazyInt localOffset, LazyInt length) {
return new LazyMemorySegment(() -> {
return data.asSlice(headerOffset + localOffset.get(), length.get());
});
}
Expand All @@ -415,8 +415,8 @@ public static LazyByteData readLazySlice(MemorySegment data, long headerOffset,
*
* @return Lazily populated long slice.
*/
public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffset, LazyInt localOffset, LazyLong length) {
return new LazyByteData(() -> {
public static LazyMemorySegment readLazyLongSlice(MemorySegment data, long headerOffset, LazyInt localOffset, LazyLong length) {
return new LazyMemorySegment(() -> {
return data.asSlice(headerOffset + localOffset.get(), length.get());
});
}
Expand All @@ -431,8 +431,8 @@ public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffs
*
* @return Lazily populated long slice.
*/
public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffset, LazyLong localOffset, LazyLong length) {
return new LazyByteData(() -> {
public static LazyMemorySegment readLazyLongSlice(MemorySegment data, long headerOffset, LazyLong localOffset, LazyLong length) {
return new LazyMemorySegment(() -> {
return data.asSlice(headerOffset + localOffset.get(), length.get());
});
}
Expand All @@ -447,8 +447,8 @@ public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffs
*
* @return Lazily populated long slice.
*/
public static LazyByteData readLazyLongSlice(MemorySegment data, long headerOffset, LazyInt localOffset, long length) {
return new LazyByteData(() -> {
public static LazyMemorySegment readLazyLongSlice(MemorySegment data, long headerOffset, LazyInt localOffset, long length) {
return new LazyMemorySegment(() -> {
return data.asSlice(headerOffset + localOffset.get(), length);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
/**
* Lazy {@link MemorySegment} getter.
*/
public class LazyByteData extends Lazy<Supplier<MemorySegment>> {
public class LazyMemorySegment extends Lazy<Supplier<MemorySegment>> {
private MemorySegment value;

/**
* @param lookup
* Lazy lookup.
*/
public LazyByteData(@Nonnull Supplier<MemorySegment> lookup) {
public LazyMemorySegment(@Nonnull Supplier<MemorySegment> lookup) {
super(lookup);
}

/**
* @return Copy.
*/
@Nonnull
public LazyByteData copy() {
LazyByteData copy = new LazyByteData(lookup);
public LazyMemorySegment copy() {
LazyMemorySegment copy = new LazyMemorySegment(lookup);
copy.id = id;
if (set) copy.set(value);
return copy;
Expand Down Expand Up @@ -61,7 +61,7 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

LazyByteData that = (LazyByteData) o;
LazyMemorySegment that = (LazyMemorySegment) o;

return Objects.equals(get(), that.get());
}
Expand Down

0 comments on commit 905d881

Please sign in to comment.