Skip to content

Commit

Permalink
lab function inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
gco-bmx committed Dec 28, 2024
1 parent 9e0fc72 commit 44eb8cd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions labs/core_bound/function_inlining_1/solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include <algorithm>
#include <stdlib.h>

static int compare(const void *lhs, const void *rhs) {
auto &a = *reinterpret_cast<const S *>(lhs);
auto &b = *reinterpret_cast<const S *>(rhs);
static int compare(const S &a, const S &b) {

if (a.key1 < b.key1)
return -1;
Expand All @@ -23,5 +21,6 @@ static int compare(const void *lhs, const void *rhs) {
}

void solution(std::array<S, N> &arr) {
qsort(arr.data(), arr.size(), sizeof(S), compare);
//templated so in thoery it inlines..
std::sort(arr.begin(), arr.end(), compare);
}

0 comments on commit 44eb8cd

Please sign in to comment.