Skip to content

Commit

Permalink
Replace use of new with make_unique
Browse files Browse the repository at this point in the history
  • Loading branch information
martincapello committed Jan 5, 2023
1 parent 6c886cf commit 03f0c7f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/dio/aseprite_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ bool AsepriteDecoder::decode()

// Create the new sprite
std::unique_ptr<doc::Sprite> sprite(
new doc::Sprite(doc::ImageSpec(header.depth == 32 ? doc::ColorMode::RGB:
header.depth == 16 ? doc::ColorMode::GRAYSCALE:
doc::ColorMode::INDEXED,
header.width,
header.height),
header.ncolors));
std::make_unique<doc::Sprite>(doc::ImageSpec(header.depth == 32 ? doc::ColorMode::RGB:
header.depth == 16 ? doc::ColorMode::GRAYSCALE:
doc::ColorMode::INDEXED,
header.width,
header.height),
header.ncolors));

// Set frames and speed
sprite->setTotalFrames(doc::frame_t(header.frames));
Expand Down Expand Up @@ -784,7 +784,7 @@ doc::Cel* AsepriteDecoder::readCelChunk(doc::Sprite* sprite,
break;
}

cel.reset(new doc::Cel(frame, image));
cel = std::make_unique<doc::Cel>(frame, image);
cel->setPosition(x, y);
cel->setOpacity(opacity);
}
Expand Down Expand Up @@ -825,7 +825,7 @@ doc::Cel* AsepriteDecoder::readCelChunk(doc::Sprite* sprite,
doc::ImageRef image(doc::Image::create(pixelFormat, w, h));
read_compressed_image(f(), delegate(), image.get(), header, chunk_end);

cel.reset(new doc::Cel(frame, image));
cel = std::make_unique<doc::Cel>(frame, image);
cel->setPosition(x, y);
cel->setOpacity(opacity);
}
Expand Down Expand Up @@ -870,7 +870,7 @@ doc::Cel* AsepriteDecoder::readCelChunk(doc::Sprite* sprite,
return doc::tile_geti(tile) >= tilesetSize ? doc::notile : tile;
});

cel.reset(new doc::Cel(frame, image));
cel = std::make_unique<doc::Cel>(frame, image);
cel->setPosition(x, y);
cel->setOpacity(opacity);
}
Expand Down Expand Up @@ -1075,7 +1075,7 @@ doc::Slice* AsepriteDecoder::readSliceChunk(doc::Slices& slices)
read32(); // 4 bytes reserved
std::string name = readString(); // Name

std::unique_ptr<doc::Slice> slice(new doc::Slice);
std::unique_ptr<doc::Slice> slice(std::make_unique<doc::Slice>());
slice->setName(name);

// For each key
Expand Down

0 comments on commit 03f0c7f

Please sign in to comment.