Skip to content

Commit

Permalink
Pass small trivially-copyable types by value
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed May 12, 2024
1 parent 1df283d commit 4f32de7
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion utils/makemhr/loaddef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ auto AverageHrirOnset(PPhaseResampler &rs, al::span<double> upsampled, const uin
{
rs.process(hrir, upsampled);

auto abs_lt = [](const double &lhs, const double &rhs) -> bool
auto abs_lt = [](const double lhs, const double rhs) -> bool
{ return std::abs(lhs) < std::abs(rhs); };
auto iter = std::max_element(upsampled.cbegin(), upsampled.cend(), abs_lt);
return Lerp(onset, static_cast<double>(std::distance(upsampled.cbegin(), iter))/(10*rate), f);
Expand Down
2 changes: 1 addition & 1 deletion utils/makemhr/loadsofa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ auto CalcHrirOnset(PPhaseResampler &rs, const uint rate, al::span<double> upsamp
{
rs.process(hrir, upsampled);

auto abs_lt = [](const double &lhs, const double &rhs) -> bool
auto abs_lt = [](const double lhs, const double rhs) -> bool
{ return std::abs(lhs) < std::abs(rhs); };
auto iter = std::max_element(upsampled.cbegin(), upsampled.cend(), abs_lt);
return static_cast<double>(std::distance(upsampled.cbegin(), iter)) /
Expand Down
4 changes: 2 additions & 2 deletions utils/makemhr/makemhr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ void SynthesizeHrirs(HrirDataT *hData)
*/
FftForward(static_cast<uint>(htemp.size()), htemp.data());
std::transform(htemp.cbegin(), htemp.cbegin()+m, filter.begin(),
[](const complex_d &c) -> double { return std::abs(c); });
[](const complex_d c) -> double { return std::abs(c); });

for(uint ai{0u};ai < field.mEvs[ei].mAzs.size();ai++)
{
Expand Down Expand Up @@ -824,7 +824,7 @@ void SynthesizeHrirs(HrirDataT *hData)
}
FftForward(static_cast<uint>(htemp.size()), htemp.data());
std::transform(htemp.cbegin(), htemp.cbegin()+m, filter.begin(),
[](const complex_d &c) -> double { return std::abs(c); });
[](const complex_d c) -> double { return std::abs(c); });

for(uint ti{0u};ti < channels;ti++)
{
Expand Down
2 changes: 1 addition & 1 deletion utils/sofa-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void PrintCompatibleLayout(const al::span<const float> xyzs)
}

// Load and inspect the given SOFA file.
void SofaInfo(const std::string filename)
void SofaInfo(const std::string &filename)
{
int err;
MySofaHrtfPtr sofa{mysofa_load(filename.c_str(), &err)};
Expand Down
2 changes: 1 addition & 1 deletion utils/sofa-support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using double3 = std::array<double,3>;
* equality of unique elements.
*/
std::vector<double> GetUniquelySortedElems(const std::vector<double3> &aers, const uint axis,
const std::array<const double*,3> filters, const std::array<double,3> epsilons)
const std::array<const double*,3> &filters, const std::array<double,3> &epsilons)
{
std::vector<double> elems;
for(const double3 &aer : aers)
Expand Down
5 changes: 2 additions & 3 deletions utils/uhjdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ void fwrite32le(uint val, FILE *f)
fwrite(data.data(), 1, data.size(), f);
}

byte4 f32AsLEBytes(const float &value)
byte4 f32AsLEBytes(const float value)
{
byte4 ret{};
std::memcpy(ret.data(), &value, 4);
auto ret = al::bit_cast<byte4>(value);
if constexpr(al::endian::native == al::endian::big)
{
std::swap(ret[0], ret[3]);
Expand Down
2 changes: 1 addition & 1 deletion utils/uhjencoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ int main(al::span<std::string_view> args)
continue;

const auto spkr = std::find_if(spkrs.cbegin(), spkrs.cend(),
[chanid](const SpeakerPos &pos){return pos.mChannelID == chanid;});
[chanid](const SpeakerPos pos){return pos.mChannelID == chanid;});
if(spkr == spkrs.cend())
{
fprintf(stderr, " ... failed to find channel ID %d\n", chanid);
Expand Down

0 comments on commit 4f32de7

Please sign in to comment.