summaryrefslogtreecommitdiff
path: root/fluid/io/Code_Writer.h
diff options
context:
space:
mode:
Diffstat (limited to 'fluid/io/Code_Writer.h')
-rw-r--r--fluid/io/Code_Writer.h59
1 files changed, 50 insertions, 9 deletions
diff --git a/fluid/io/Code_Writer.h b/fluid/io/Code_Writer.h
index c199197ec..9d52e0600 100644
--- a/fluid/io/Code_Writer.h
+++ b/fluid/io/Code_Writer.h
@@ -23,14 +23,55 @@
#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <string>
-#include <set>
-#include <map>
class Node;
-struct Fd_Identifier_Tree;
-struct Fd_Text_Tree;
-struct Fd_Pointer_Tree;
+
+/** Simple string-to-pointer map entry */
+struct Fd_Id_Entry {
+ char *key;
+ void *value;
+};
+
+/** Simple string-to-pointer map (unsorted array, linear search) */
+struct Fd_Id_Map {
+ Fd_Id_Entry *entries;
+ int count;
+ int capacity;
+
+ Fd_Id_Map() : entries(0), count(0), capacity(0) {}
+ ~Fd_Id_Map() { clear(); }
+ void clear();
+ const char *find_or_insert(const char *key, void *value, void **found_value);
+};
+
+/** Simple string set (unsorted array, linear search) */
+struct Fd_String_Set {
+ char **strings;
+ int count;
+ int capacity;
+
+ Fd_String_Set() : strings(0), count(0), capacity(0) {}
+ ~Fd_String_Set() { clear(); }
+ void clear();
+ bool contains(const char *s);
+ void insert(const char *s);
+};
+
+/** Simple pointer set (unsorted array, linear search) */
+struct Fd_Pointer_Set {
+ void **pointers;
+ int count;
+ int capacity;
+
+ Fd_Pointer_Set() : pointers(0), count(0), capacity(0) {}
+ ~Fd_Pointer_Set() { clear(); }
+ void clear();
+ bool contains(void *p);
+ void insert(void *p);
+};
int is_id(char c);
@@ -52,13 +93,13 @@ private:
FILE *header_file = nullptr;
/// tree of unique but human-readable identifiers
- std::map<std::string, void*> unique_id_list { };
+ Fd_Id_Map unique_id_list;
/// searchable text tree for text that is only written once to the header file
- std::set<std::string> text_in_header { };
+ Fd_String_Set text_in_header;
/// searchable text tree for text that is only written once to the code file
- std::set<std::string> text_in_code { };
+ Fd_String_Set text_in_code;
/// searchable tree for pointers that are only written once to the code file
- std::set<void*> ptr_in_code { };
+ Fd_Pointer_Set ptr_in_code;
/// crc32 for blocks of text written to the code file
unsigned long block_crc_ = 0;