Skip to content

Commit

Permalink
remove ranges header
Browse files Browse the repository at this point in the history
  • Loading branch information
jstkdng committed Aug 5, 2023
1 parent acbfa5a commit 212ad6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/canvas/iterm2/iterm2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <fstream>
#include <iostream>
#include <filesystem>
#include <ranges>
#include <algorithm>

#include <spdlog/spdlog.h>
#include <fmt/format.h>
Expand Down Expand Up @@ -92,13 +92,13 @@ void Iterm2::draw()
str.clear();
}

auto Iterm2::process_chunks(const std::string_view filename, int chunk_size, size_t num_bytes) -> std::vector<std::unique_ptr<Iterm2Chunk>>
auto Iterm2::process_chunks(const std::string& filename, int chunk_size, size_t num_bytes) -> std::vector<std::unique_ptr<Iterm2Chunk>>
{
const int num_chunks = std::ceil(static_cast<double>(num_bytes) / chunk_size);
std::vector<std::unique_ptr<Iterm2Chunk>> chunks;
chunks.reserve(num_chunks + 2);

std::ifstream ifs (filename.data());
std::ifstream ifs (filename);
while (ifs.good()) {
auto chunk = std::make_unique<Iterm2Chunk>(chunk_size);
ifs.read(chunk->get_buffer(), chunk_size);
Expand All @@ -107,9 +107,9 @@ auto Iterm2::process_chunks(const std::string_view filename, int chunk_size, siz
}

#ifdef HAVE_STD_EXECUTION_H
std::for_each(std::execution::par_unseq, std::begin(chunks), std::end(chunks), Iterm2Chunk::process_chunk);
std::for_each(std::execution::par_unseq, chunks.begin(), chunks.end(), Iterm2Chunk::process_chunk);
#else
oneapi::tbb::parallel_for_each(std::begin(chunks), std::end(chunks), Iterm2Chunk());
oneapi::tbb::parallel_for_each(chunks.begin(), chunks.end(), Iterm2Chunk());
#endif

return chunks;
Expand Down
3 changes: 1 addition & 2 deletions src/canvas/iterm2/iterm2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <string>
#include <vector>
#include <mutex>
#include <string_view>

class Iterm2Chunk;
class Image;
Expand All @@ -45,7 +44,7 @@ class Iterm2 : public Window
int horizontal_cells = 0;
int vertical_cells = 0;

static auto process_chunks(std::string_view filename, int chunk_size, size_t num_bytes) -> std::vector<std::unique_ptr<Iterm2Chunk>>;
static auto process_chunks(const std::string& filename, int chunk_size, size_t num_bytes) -> std::vector<std::unique_ptr<Iterm2Chunk>>;
};

#endif

0 comments on commit 212ad6c

Please sign in to comment.