Change: Use std::make_unique instead of passing new() (#12539)

This commit is contained in:
Peter Nelson 2024-04-20 11:20:49 +01:00 committed by GitHub
parent fc7f184dbd
commit a1a01e21cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 7 additions and 6 deletions

View File

@ -218,7 +218,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
*/
if (this->buffer == nullptr) return nullptr;
std::unique_ptr<FallbackLine> l(new FallbackLine());
std::unique_ptr<FallbackLine> l = std::make_unique<FallbackLine>();
if (*this->buffer == '\0') {
/* Only a newline. */

View File

@ -489,7 +489,7 @@ std::unique_ptr<const ICUParagraphLayout::Line> ICUParagraphLayout::NextLine(int
ubidi_reorderVisual(bidi_level.data(), bidi_level.size(), vis_to_log.data());
/* Create line. */
std::unique_ptr<ICULine> line(new ICULine());
std::unique_ptr<ICULine> line = std::make_unique<ICULine>();
int cur_pos = 0;
for (auto &i : vis_to_log) {

View File

@ -517,7 +517,7 @@ int openttd_main(std::span<char * const> arguments)
std::string sounds_set;
std::string music_set;
Dimension resolution = {0, 0};
std::unique_ptr<AfterNewGRFScan> scanner(new AfterNewGRFScan());
std::unique_ptr<AfterNewGRFScan> scanner = std::make_unique<AfterNewGRFScan>();
bool dedicated = false;
bool only_local_path = false;

View File

@ -224,7 +224,8 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
CFAutoRelease<CTLineRef> line(CTTypesetterCreateLine(this->typesetter.get(), CFRangeMake(this->cur_offset, len)));
this->cur_offset += len;
return std::unique_ptr<const Line>(line ? new CoreTextLine(std::move(line), this->font_map, this->text_buffer) : nullptr);
if (!line) return nullptr;
return std::make_unique<CoreTextLine>(std::move(line), this->font_map, this->text_buffer);
}
CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff) : font(font)

View File

@ -405,7 +405,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
if (FAILED(ScriptLayout((int)bidi_level.size(), &bidi_level[0], &vis_to_log[0], nullptr))) return nullptr;
/* Create line. */
std::unique_ptr<UniscribeLine> line(new UniscribeLine());
std::unique_ptr<UniscribeLine> line = std::make_unique<UniscribeLine>();
int cur_pos = 0;
for (std::vector<INT>::iterator l = vis_to_log.begin(); l != vis_to_log.end(); l++) {

View File

@ -68,7 +68,7 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f
*/
if (num < 0 || num > 64 * 1024 * 1024) return WarnCorruptSprite(file, file_pos, __LINE__);
std::unique_ptr<uint8_t[]> dest_orig(new uint8_t[num]);
std::unique_ptr<uint8_t[]> dest_orig = std::make_unique<uint8_t[]>(num);
uint8_t *dest = dest_orig.get();
const int64_t dest_size = num;