Skip to content

Commit

Permalink
🎨 added sliding window iterator + refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
lamarrr committed Dec 4, 2024
1 parent 9bfffd6 commit d46e28f
Show file tree
Hide file tree
Showing 11 changed files with 277 additions and 212 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: false
LineEnding: LF
LineEnding: CRLF
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ else()
-Wno-nullability-extension)
else()
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/W3 /Zc:preprocessor)
add_compile_options(/W3 /Zc:preprocessor /permissive)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()
endif()
Expand Down
3 changes: 1 addition & 2 deletions ashura/engine/font_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ Result<Dyn<Font *>, FontErr> Font::decode(Span<u8 const> encoded, u32 face,
if (ft_postscript_name != nullptr)
{
postscript_name_size = strlen(ft_postscript_name);
if (!postscript_name.extend(
Span{ft_postscript_name, postscript_name_size}))
if (!postscript_name.extend(Span{ft_postscript_name, postscript_name_size}))
{
return Err{FontErr::OutOfMemory};
}
Expand Down
2 changes: 1 addition & 1 deletion ashura/engine/shader.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// SPDX-License-Identifier: MIT
#pragma once

#include "ashura/std/vec.h"
#include "ashura/std/log.h"
#include "ashura/std/types.h"
#include "ashura/std/vec.h"

namespace ash
{
Expand Down
4 changes: 2 additions & 2 deletions ashura/std/async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,10 @@ void Scheduler::init(AllocatorImpl allocator, std::thread::id main_thread_id,
u32 const num_worker_threads = worker_thread_sleep.size32();

impl->dedicated_threads =
pin_vec<TaskThread>(num_dedicated_threads, allocator).unwrap();
PinVec<TaskThread>::make(num_dedicated_threads, allocator).unwrap();

impl->worker_threads =
pin_vec<TaskThread>(num_worker_threads, allocator).unwrap();
PinVec<TaskThread>::make(num_worker_threads, allocator).unwrap();

for (u32 i = 0; i < num_dedicated_threads; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion ashura/std/async.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include "ashura/std/allocator.h"
#include "ashura/std/cfg.h"
#include "ashura/std/error.h"
#include "ashura/std/tuple.h"
#include "ashura/std/mem.h"
#include "ashura/std/rc.h"
#include "ashura/std/result.h"
#include "ashura/std/time.h"
#include "ashura/std/tuple.h"
#include "ashura/std/types.h"

#include <atomic>
Expand Down
6 changes: 0 additions & 6 deletions ashura/std/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ constexpr Buffer<T> buffer(Span<T> span)
return Buffer<T>{.data_ = span.data(), .capacity_ = span.size(), .size_ = 0};
}

template <typename T>
constexpr Span<T> span(Buffer<T> buffer)
{
return Span<T>{buffer.data(), buffer.size()};
}

/// @capacity: must be a non-zero power of 2
template <typename T>
struct [[nodiscard]] RingBuffer
Expand Down
10 changes: 5 additions & 5 deletions ashura/std/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ struct [[nodiscard]] Map
{
break;
}
iter_++;
probe_++;
++iter_;
++probe_;
}
}

constexpr Iter & operator++()
{
// advancement past the current element must occur
iter_++;
probe_++;
++iter_;
++probe_;

seek();

Expand All @@ -78,7 +78,7 @@ struct [[nodiscard]] Map
return *probe_;
}

constexpr bool operator!=(IterEnd const &) const
constexpr bool operator!=(IterEnd) const
{
return iter_ != end_;
}
Expand Down
Loading

0 comments on commit d46e28f

Please sign in to comment.