Skip to content

Commit 8cc098a

Browse files
committed
Removing the need for const_cast.
1 parent 5b91616 commit 8cc098a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

third_party/imgui_memory_editor/imgui_memory_editor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void MemoryEditor::CalcSizes(Sizes& s, size_t mem_size)
8080
if (PushMonoFont) ImGui::PopFont();
8181
}
8282

83-
ImU8 MemoryEditor::ReadByte(size_t addr)
83+
ImU8 MemoryEditor::ReadByte(size_t addr) const
8484
{
8585
if (Cache.BulkReadFn) return Cache.read(addr);
8686
if (ReadFn) return ReadFn(addr);
@@ -567,7 +567,7 @@ void MemoryEditor::DrawPreviewData(size_t addr, size_t mem_size, ImGuiDataType d
567567
size_t elem_size = DataTypeGetSize(data_type);
568568
size_t size = addr + elem_size > mem_size ? mem_size - addr : elem_size;
569569
for (int i = 0, n = (int)size; i < n; ++i)
570-
buf[i] = const_cast<MemoryEditor*>(this)->ReadByte(addr + i);
570+
buf[i] = ReadByte(addr + i);
571571

572572
if (data_format == DataFormat_Bin)
573573
{

third_party/imgui_memory_editor/imgui_memory_editor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct MemoryEditor
127127
size_t m_totalSize = 0;
128128
};
129129

130-
ReadCache Cache;
130+
mutable ReadCache Cache;
131131

132132
private:
133133
// [Internal State]
@@ -186,6 +186,6 @@ struct MemoryEditor
186186

187187
private:
188188
// [Internal]
189-
ImU8 ReadByte(size_t addr);
189+
ImU8 ReadByte(size_t addr) const;
190190
void DrawPreviewData(size_t addr, size_t mem_size, ImGuiDataType data_type, DataFormat data_format, char* out_buf, size_t out_buf_size) const;
191191
};

0 commit comments

Comments
 (0)