Merge pull request #5570 from FearlessTobi/port-4698

Port yuzu-emu/yuzu#4698: "General: Make use of std::nullopt where applicable"
This commit is contained in:
Pengfei Zhu 2020-10-04 06:01:51 -05:00 committed by GitHub
commit 1c8461fdea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 9 deletions

View file

@ -55,7 +55,7 @@ std::optional<BinaryResponse> NullDecoder::ProcessRequest(const BinaryRequest& r
return response;
default:
LOG_ERROR(Audio_DSP, "Got unknown binary request: {}", static_cast<u16>(request.cmd));
return {};
return std::nullopt;
}
};
} // namespace AudioCore::HLE

View file

@ -104,7 +104,7 @@ WMFDecoder::Impl::~Impl() {
std::optional<BinaryResponse> WMFDecoder::Impl::ProcessRequest(const BinaryRequest& request) {
if (request.codec != DecoderCodec::AAC) {
LOG_ERROR(Audio_DSP, "Got unknown codec {}", static_cast<u16>(request.codec));
return {};
return std::nullopt;
}
switch (request.cmd) {
@ -123,7 +123,7 @@ std::optional<BinaryResponse> WMFDecoder::Impl::ProcessRequest(const BinaryReque
}
default:
LOG_ERROR(Audio_DSP, "Got unknown binary request: {}", static_cast<u16>(request.cmd));
return {};
return std::nullopt;
}
}
@ -205,7 +205,7 @@ std::optional<BinaryResponse> WMFDecoder::Impl::Decode(const BinaryRequest& requ
if (request.src_addr < Memory::FCRAM_PADDR ||
request.src_addr + request.size > Memory::FCRAM_PADDR + Memory::FCRAM_SIZE) {
LOG_ERROR(Audio_DSP, "Got out of bounds src_addr {:08x}", request.src_addr);
return {};
return std::nullopt;
}
u8* data = memory.GetFCRAMPointer(request.src_addr - Memory::FCRAM_PADDR);
@ -269,7 +269,7 @@ std::optional<BinaryResponse> WMFDecoder::Impl::Decode(const BinaryRequest& requ
request.dst_addr_ch0 + out_streams[0].size() >
Memory::FCRAM_PADDR + Memory::FCRAM_SIZE) {
LOG_ERROR(Audio_DSP, "Got out of bounds dst_addr_ch0 {:08x}", request.dst_addr_ch0);
return {};
return std::nullopt;
}
std::memcpy(memory.GetFCRAMPointer(request.dst_addr_ch0 - Memory::FCRAM_PADDR),
out_streams[0].data(), out_streams[0].size());
@ -280,7 +280,7 @@ std::optional<BinaryResponse> WMFDecoder::Impl::Decode(const BinaryRequest& requ
request.dst_addr_ch1 + out_streams[1].size() >
Memory::FCRAM_PADDR + Memory::FCRAM_SIZE) {
LOG_ERROR(Audio_DSP, "Got out of bounds dst_addr_ch1 {:08x}", request.dst_addr_ch1);
return {};
return std::nullopt;
}
std::memcpy(memory.GetFCRAMPointer(request.dst_addr_ch1 - Memory::FCRAM_PADDR),
out_streams[1].data(), out_streams[1].size());

View file

@ -234,7 +234,7 @@ std::optional<u32> MemoryRegionInfo::LinearAllocate(u32 size) {
}
// No sufficient block found
return {};
return std::nullopt;
}
void MemoryRegionInfo::Free(u32 offset, u32 size) {

View file

@ -928,7 +928,7 @@ std::optional<ProgramResult> DecompileProgram(const Pica::Shader::ProgramCode& p
return {ProgramResult{generator.MoveShaderCode()}};
} catch (const DecompileFail& exception) {
LOG_INFO(HW_GPU, "Shader decompilation failed: {}", exception.what());
return {};
return std::nullopt;
}
}

View file

@ -1651,7 +1651,7 @@ std::optional<ShaderDecompiler::ProgramResult> GenerateVertexShader(
get_output_reg, config.state.sanitize_mul);
if (!program_source_opt)
return {};
return std::nullopt;
std::string& program_source = program_source_opt->code;