1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-09 01:29:44 +00:00

Switches to std::make_shared/make_unique in a bunch of applicable places.

No doubt many more similar improvements are available, these are just the ones that were easy to find.
This commit is contained in:
Thomas Harte 2019-12-21 23:34:25 -05:00
parent 25da5ebdae
commit e9318efeb6
8 changed files with 16 additions and 17 deletions

View File

@ -10,7 +10,7 @@
#include "Target.hpp"
Analyser::Static::TargetList Analyser::Static::AppleII::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms) {
auto target = std::unique_ptr<Target>(new Target);
auto target = std::make_unique<Target>();
target->machine = Machine::AppleII;
target->media = media;

View File

@ -14,7 +14,7 @@ namespace {
Appends a Boolean selection of @c selection for option @c name to @c selection_set.
*/
void append_bool(Configurable::SelectionSet &selection_set, const std::string &name, bool selection) {
selection_set[name] = std::unique_ptr<Configurable::Selection>(new Configurable::BooleanSelection(selection));
selection_set[name] = std::make_unique<Configurable::BooleanSelection>(selection);
}
/*!
@ -64,7 +64,7 @@ void Configurable::append_display_selection(Configurable::SelectionSet &selectio
case Display::CompositeMonochrome: string_selection = "composite-mono"; break;
case Display::CompositeColour: string_selection = "composite"; break;
}
selection_set["display"] = std::unique_ptr<Configurable::Selection>(new Configurable::ListSelection(string_selection));
selection_set["display"] = std::make_unique<Configurable::ListSelection>(string_selection);
}
void Configurable::append_quick_boot_selection(Configurable::SelectionSet &selection_set, bool selection) {

View File

@ -67,7 +67,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES"

View File

@ -111,8 +111,7 @@ class ActivityObserver: public Activity::Observer {
const float right_x = 1.0f - 2.0f * width;
float y = 1.0f - 2.0f * height;
for(const auto &drive: drives_) {
// TODO: use std::make_unique as below, if/when formally embracing C++14.
lights_.emplace(std::make_pair(drive, std::unique_ptr<Outputs::Display::OpenGL::Rectangle>(new Outputs::Display::OpenGL::Rectangle(right_x, y, width, height))));
lights_.emplace(std::make_pair(drive, std::make_unique<Outputs::Display::OpenGL::Rectangle>(right_x, y, width, height)));
y -= height * 2.0f;
}

View File

@ -470,11 +470,11 @@ std::unique_ptr<Shader> ScanTarget::conversion_shader() const {
"fragColour = vec4(fragColour3, 0.64);"
"}";
return std::unique_ptr<Shader>(new Shader(
return std::make_unique<Shader>(
vertex_shader,
fragment_shader,
bindings(ShaderType::Conversion)
));
);
}
std::unique_ptr<Shader> ScanTarget::composition_shader() const {
@ -544,11 +544,11 @@ std::unique_ptr<Shader> ScanTarget::composition_shader() const {
break;
}
return std::unique_ptr<Shader>(new Shader(
return std::make_unique<Shader>(
vertex_shader,
fragment_shader + "}",
bindings(ShaderType::Composition)
));
);
}
std::unique_ptr<Shader> ScanTarget::qam_separation_shader() const {
@ -656,9 +656,9 @@ std::unique_ptr<Shader> ScanTarget::qam_separation_shader() const {
"fragColour = fragColour*0.5 + vec4(0.5);"
"}";
return std::unique_ptr<Shader>(new Shader(
return std::make_unique<Shader>(
vertex_shader,
fragment_shader,
bindings(ShaderType::QAMSeparation)
));
);
}

View File

@ -136,5 +136,5 @@ std::shared_ptr<Track> D64::get_track_at_position(Track::Address address) {
Encodings::CommodoreGCR::encode_block(&sector_data[target_data_offset], end_of_data);
}
return std::shared_ptr<Track>(new PCMTrack(PCMSegment(data)));
return std::make_shared<PCMTrack>(PCMSegment(data));
}

View File

@ -121,7 +121,7 @@ std::shared_ptr<Track> WOZ::get_track_at_position(Track::Address address) {
number_of_bits = std::min(file_.get16le(), static_cast<uint16_t>(6646*8));
}
return std::shared_ptr<PCMTrack>(new PCMTrack(PCMSegment(number_of_bits, track_contents)));
return std::make_shared<PCMTrack>(PCMSegment(number_of_bits, track_contents));
}
void WOZ::set_tracks(const std::map<Track::Address, std::shared_ptr<Track>> &tracks) {

View File

@ -236,7 +236,7 @@ template<class T> std::shared_ptr<Storage::Disk::Track>
// Allow the amount of data written to be up to 10% more than the expected size. Which is generous.
if(segment.data.size() > max_size) segment.data.resize(max_size);
return std::shared_ptr<Storage::Disk::Track>(new Storage::Disk::PCMTrack(std::move(segment)));
return std::make_shared<Storage::Disk::PCMTrack>(std::move(segment));
}
Encoder::Encoder(std::vector<bool> &target) :
@ -311,9 +311,9 @@ std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetMFMTrackWithSe
}
std::unique_ptr<Encoder> Storage::Encodings::MFM::GetMFMEncoder(std::vector<bool> &target) {
return std::unique_ptr<Encoder>(new MFMEncoder(target));
return std::make_unique<MFMEncoder>(target);
}
std::unique_ptr<Encoder> Storage::Encodings::MFM::GetFMEncoder(std::vector<bool> &target) {
return std::unique_ptr<Encoder>(new FMEncoder(target));
return std::make_unique<FMEncoder>(target);
}