aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--azalea-nbt/benches/my_benchmark.rs6
-rw-r--r--azalea-nbt/src/encode.rs14
-rw-r--r--azalea-nbt/src/tag.rs2
3 files changed, 10 insertions, 12 deletions
diff --git a/azalea-nbt/benches/my_benchmark.rs b/azalea-nbt/benches/my_benchmark.rs
index c77928d8..be114005 100644
--- a/azalea-nbt/benches/my_benchmark.rs
+++ b/azalea-nbt/benches/my_benchmark.rs
@@ -16,13 +16,13 @@ fn bench_serialize(filename: &str, c: &mut Criterion) {
let mut decoded_src_decoder = GzDecoder::new(&mut src);
let mut decoded_src = Vec::new();
decoded_src_decoder.read_to_end(&mut decoded_src).unwrap();
- let mut decoded_src_stream = std::io::Cursor::new(decoded_src);
+ let mut decoded_src_stream = std::io::Cursor::new(decoded_src.clone());
file.seek(SeekFrom::Start(0)).unwrap();
let nbt = Tag::read_gzip(&mut file).unwrap();
let mut group = c.benchmark_group(filename);
- group.throughput(Throughput::Bytes(contents.len() as u64));
+ group.throughput(Throughput::Bytes(decoded_src.len() as u64));
group.bench_function("Decode", |b| {
b.iter(|| {
decoded_src_stream.seek(SeekFrom::Start(0)).unwrap();
@@ -38,7 +38,7 @@ fn bench_serialize(filename: &str, c: &mut Criterion) {
}
fn bench(c: &mut Criterion) {
- // bench_serialize("tests/bigtest.nbt", c);
+ bench_serialize("tests/bigtest.nbt", c);
// bench_serialize("tests/simple_player.dat", c);
// bench_serialize("tests/complex_player.dat", c);
bench_serialize("tests/level.dat", c);
diff --git a/azalea-nbt/src/encode.rs b/azalea-nbt/src/encode.rs
index 8bed2681..9ce4faf4 100644
--- a/azalea-nbt/src/encode.rs
+++ b/azalea-nbt/src/encode.rs
@@ -40,8 +40,8 @@ impl Tag {
writer
.write_i32::<BE>(value.len() as i32)
.map_err(|_| Error::WriteError)?;
- for byte in value {
- writer.write_i8(*byte).map_err(|_| Error::WriteError)?;
+ for &byte in value {
+ writer.write_i8(byte).map_err(|_| Error::WriteError)?;
}
}
Tag::String(value) => {
@@ -77,19 +77,17 @@ impl Tag {
writer
.write_i32::<BE>(value.len() as i32)
.map_err(|_| Error::WriteError)?;
- for int in value {
- writer
- .write_i32::<BE>(*int)
- .map_err(|_| Error::WriteError)?;
+ for &int in value {
+ writer.write_i32::<BE>(int).map_err(|_| Error::WriteError)?;
}
}
Tag::LongArray(value) => {
writer
.write_i32::<BE>(value.len() as i32)
.map_err(|_| Error::WriteError)?;
- for long in value {
+ for &long in value {
writer
- .write_i64::<BE>(*long)
+ .write_i64::<BE>(long)
.map_err(|_| Error::WriteError)?;
}
}
diff --git a/azalea-nbt/src/tag.rs b/azalea-nbt/src/tag.rs
index 3ebf63b6..f11b8889 100644
--- a/azalea-nbt/src/tag.rs
+++ b/azalea-nbt/src/tag.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;
-#[derive(Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq)]
pub enum Tag {
End, // 0
Byte(i8), // 1