Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelkn committed Jan 4, 2024
1 parent 8beb2b9 commit 0a1f259
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
FROM ubuntu:latest
FROM alpine:3.19.0

WORKDIR /usr/src/app
WORKDIR /app

RUN apt-get update; \
apt-get install -y --no-install-recommends make g++ libgtest-dev cmake; \
rm -rf /var/lib/apt/lists/*
RUN apk update && \
apk add --no-cache build-base cmake gtest-dev

COPY . .

Expand Down
15 changes: 3 additions & 12 deletions src/rainflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,16 @@ RainFlow::Counts RainFlow::count_cycles(const RainFlow::Series& series, double b
nmax = n;

auto range = n * binSize;
if (counts.find(range) == counts.end()) {
counts[range] = cycle.count;
} else {
counts[range] += cycle.count;
}
counts[range] += cycle.count;
}

for (auto n = 1; n < nmax; ++n) {
auto range = n * binSize;
if (counts.find(range) == counts.end())
counts[range] = 0.0;
counts.emplace(range, 0.0);
}
} else {
for (auto cycle: extract_cycles(series)) {
if (counts.find(cycle.range) == counts.end()) {
counts[cycle.range] = cycle.count;
} else {
counts[cycle.range] += cycle.count;
}
counts[cycle.range] += cycle.count;
}
}

Expand Down

0 comments on commit 0a1f259

Please sign in to comment.