Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Test in Browser</title>
<script src="https://cdn.jsdelivr.net/npm/object-assign-polyfill@0.1.0/index.min.js"></script>
<script src="./dist/immer.umd.js"></script>
</head>
<body>
#0 0x00007ffff7267860 in QAction::isChecked() const () from /usr/lib/libQt5Widgets.so.5
#1 0x00007fffea87ef09 in PageView::capability (this=0x555555f23540, capability=<optimized out>) at /home/nyanpasu64/aur/okular-git/src/okular/ui/pageview.cpp:1595
#2 0x00007fffea6ba0ec in Okular::DocumentPrivate::saveViewsInfo (this=this@entry=0x555555e7a010, view=view@entry=0x555555f23580, e=...) at /home/nyanpasu64/aur/okular-git/src/okular/core/document.cpp:771
#3 0x00007fffea6d04bb in Okular::DocumentPrivate::saveDocumentInfo (this=<optimized out>) at /home/nyanpasu64/aur/okular-git/src/okular/core/document.cpp:1335
#4 0x00007fffea6d2870 in Okular::Document::closeDocument (this=0x555555e75e00) at /home/nyanpasu64/aur/okular-git/src/okular/core/document.cpp:2769
#5 Okular::Document::closeDocument (this=0x555555e75e00) at /home/nyanpasu64/aur/okular-git/src/okular/core/document.cpp:2738
#6 0x00007fffea806363 in Okular::Part::closeUrl (promptToSave=<optimized out>, this=0x555555e8cc30) at /home/nyanpasu64/aur/okula
@nyanpasu64
nyanpasu64 / 00notes.md
Last active December 9, 2019 14:53
C++ Inheritance vs Trait-like Type Erasure

This is based off of code in my current program (https://gitlab.com/nyanpasu64/exotracker-cpp).

In practice, synth_run_clocks contains a very tight loop whose interior is called up to 1.79 million times a second (once per NES clock cycle). I thought it might be faster if the innermost method call was statically dispatched. (But if the loop is complex, does it generate instruction cache bloat?)

@nyanpasu64
nyanpasu64 / gist:14740fcaff6d2671b384e1caeb32cff2
Created December 1, 2019 10:28
portaudiocpp master file list
as of portaudio commit c5d2c51bd6fe354d0ee1119ba932bfebd3ebfacc (master)
sources:
source/portaudiocpp/AsioDeviceAdapter.cxx
source/portaudiocpp/BlockingStream.cxx
source/portaudiocpp/CFunCallbackStream.cxx
source/portaudiocpp/CallbackInterface.cxx
source/portaudiocpp/CallbackStream.cxx
source/portaudiocpp/CppFunCallbackStream.cxx
C:\Users\nyanpasu\Dropbox\encrypted\code\exotracker\3rdparty\immer/detail/rbts/rrbtree.hpp(956): warning C4267: 'argument': conversion from 'size_t' to 'immer::detail::rbts::count_t', possible loss of data
C:\Users\nyanpasu\Dropbox\encrypted\code\exotracker\3rdparty\immer/detail/rbts/rrbtree.hpp(943): note: while compiling class template member function 'void immer::detail::rbts::concat_mut_lr_l(immer::detail::rbts::rrbtree<T,MemoryPolicy,5,3> &,immer::no_transience_policy::apply<immer::free_list_heap_policy<immer::cpp_heap,1024>>::type::edit,immer::detail::rbts::rrbtree<T,MemoryPolicy,5,3> &,immer::no_transience_policy::apply<immer::free_list_heap_policy<immer::cpp_heap,1024>>::type::edit)'
with
[
T=doc::TimedChannelEvent,
MemoryPolicy=immer::default_memory_policy
]
C:\Users\nyanpasu\Dropbox\encrypted\code\exotracker\3rdparty\immer/flex_vector.hpp(495): note: see reference to function template instantiation 'void immer::detail::rbts::concat_mut_lr_l(immer::deta
@nyanpasu64
nyanpasu64 / constants in vtable.md
Last active November 19, 2019 07:44
"Storing constants in vtable" is an unmet need

"Storing constants in vtable" is an unmet need

Rust doesn't allow const in trait objects.

Just like static functions, associated constants aren't stored on the method table. If the trait or any subtrait contain an associated constant, they cannot be made into an object.

this is stupid. i've used "trait object constants" or "virtual static variables" or "abstract ClassVar" in Python corrscope, and I'm using them (except as virtual methods because C++ doesn't allow virtual static properties) in C++...

and why doesn't Rust let you store constants in the trait vtable? What's the reasoning behind forcing you to call a getter instead of just letting you store constants there?

@nyanpasu64
nyanpasu64 / enum_map.h
Created November 7, 2019 01:35
Allocation-free map from an EnumT to a ValueT.
#pragma once
#include <array>
#include <cstddef>
/// EnumT can be an enum or enum class. It must define a COUNT element.
template<typename EnumT>
size_t constexpr enum_count = (size_t) EnumT::COUNT;
/// Allocation-free map from an EnumT to a ValueT.
@nyanpasu64
nyanpasu64 / AUDIO_DESIGN.md
Created October 20, 2019 08:15
Rules for avoiding circular header inclusion

Rules for avoiding circular header inclusion

C++ headers malfunction when there is an include cycle. I have designed some rules to prevent inclusion cycles (ensure topological sortability).

Abstract files (in order from common to derived). Each file can include all files listed above.

  • ../*_common.h
  • ./general_common.h
    • External libraries: none
  • ./specific_common.h
@nyanpasu64
nyanpasu64 / event_queue.h
Last active October 19, 2019 09:18
Allocation-free min priority queue which schedules a finite set of events.
#pragma once
#include <cstdint>
#include <limits>
#include <type_traits>
namespace audio {
/**
Allocation-free min priority queue which schedules a finite set of events.
@nyanpasu64
nyanpasu64 / blip_buffer.diff
Created October 16, 2019 10:31
blip_buffer 0.4.0 -> 0CC blip_buffer
diff --git a/3rdparty/Blip_Buffer/Blip_Buffer.cpp b/3rdparty/Blip_Buffer/Blip_Buffer.cpp
index cd1f9e3..dc01adb 100644
--- a/3rdparty/Blip_Buffer/Blip_Buffer.cpp
+++ b/3rdparty/Blip_Buffer/Blip_Buffer.cpp
@@ -1,6 +1,8 @@
// Blip_Buffer 0.4.0. http://www.slack.net/~ant/
+#include "../stdafx.h"
+