Fix load_symbol ignoring source when a previous source has already been loaded #83

Merged
TheBrokenRail merged 2 commits from bigjango13/minecraft-pi-reborn:sounds into master 2024-02-07 02:16:35 +00:00
Contributor

This allows for some neat things, like overloading sounds without having to replace the entire file.

This allows for some neat things, like overloading sounds without having to replace the entire file.
bigjango13 added 1 commit 2024-01-31 00:45:15 +00:00
TheBrokenRail reviewed 2024-02-07 00:06:47 +00:00
@ -18,1 +16,3 @@
binary = LIEF::ELF::Parser::parse(source);
static std::unordered_map<std::string, std::unique_ptr<LIEF::ELF::Binary>> sources = {};
auto pos = sources.find(std::string(source));
if (pos == sources.end()) {

Why not do?

static std::unordered_map<std::string, std::unique_ptr<LIEF::ELF::Binary>> sources = {};
std::string cpp_source = source;
if (sources.count(cpp_source) == 0) {
    sources[cpp_source] = LIEF::ELF::Parser::parse(source);
}
std::unique_ptr<LIEF::ELF::Binary> &binary = sources[cpp_source];
Why not do? ```c++ static std::unordered_map<std::string, std::unique_ptr<LIEF::ELF::Binary>> sources = {}; std::string cpp_source = source; if (sources.count(cpp_source) == 0) { sources[cpp_source] = LIEF::ELF::Parser::parse(source); } std::unique_ptr<LIEF::ELF::Binary> &binary = sources[cpp_source]; ```
Author
Contributor

I didn't know about .count until now. Should I change it to that?

I didn't know about `.count` until now. Should I change it to that?

Yeah, it's what the rest of Reborn uses.

Is it actually better? 🤷

But consistency is good.

Yeah, it's what the rest of Reborn uses. Is it actually better? 🤷 But consistency is good.
Author
Contributor

Done 👍

Done :+1:
bigjango13 marked this conversation as resolved
bigjango13 added 1 commit 2024-02-07 01:43:03 +00:00
TheBrokenRail merged commit c62d5264a8 into master 2024-02-07 02:16:35 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: minecraft-pi-reborn/minecraft-pi-reborn#83
No description provided.