diff --git a/Readme.md b/Readme.md index 0eefebe..7081d05 100644 --- a/Readme.md +++ b/Readme.md @@ -21,3 +21,6 @@ Syntax : TODO: * Possibly come up with a better name. * Cleanup memory usage (it hogs quite a bit or what it does..) +* Split lines of file and refactor it that way instead (better debug, problably negligable performance loss, worst case can have both depending on build type) + + diff --git a/Test/bloat.hpp b/Test/bloat.refactored.hpp similarity index 100% rename from Test/bloat.hpp rename to Test/bloat.refactored.hpp diff --git a/Test/meson.build b/Test/meson.build index 86f5880..8102404 100644 --- a/Test/meson.build +++ b/Test/meson.build @@ -9,5 +9,5 @@ if get_option('buildtype').startswith('debug') endif -executable( 'refactor', 'refactor.cpp' ) +executable( 'refactor', 'refactor.refactored.cpp' ) diff --git a/Test/refactor.cpp b/Test/refactor.refactored.cpp similarity index 96% rename from Test/refactor.cpp rename to Test/refactor.refactored.cpp index d5fa00c..adc13cb 100644 --- a/Test/refactor.cpp +++ b/Test/refactor.refactored.cpp @@ -1,5 +1,5 @@ #define ZPL_IMPLEMENTATION -#include "bloat.hpp" +#include "bloat.refactored.hpp" namespace File @@ -7,7 +7,8 @@ namespace File string Source = nullptr; string Destination = nullptr; file_contents Content {}; - zpl_arena Buffer; + + zpl_arena Buffer; void cleanup() { @@ -28,7 +29,7 @@ namespace File if ( fsize > 0 ) { - arena_init_from_allocator( & Buffer, heap(), (fsize % 64) * 2 ); + arena_init_from_allocator( & Buffer, heap(), (fsize + fsize % 64) * 4 ); Content.data = alloc( arena_allocator( & Buffer), fsize); Content.size = fsize; @@ -459,9 +460,11 @@ void refactor() if ( string_are_equal( ignore->Sig, current ) ) { - char after = content[sig_length]; + char before = content[-1]; + char after = content[sig_length]; - if ( char_is_alphanumeric( after ) || after == '_' ) + if ( char_is_alphanumeric( before ) || before == '_' + || char_is_alphanumeric( after ) || after == '_' ) { continue; } @@ -537,9 +540,11 @@ void refactor() if ( string_are_equal( word->Sig, current ) ) { - char after = content[sig_length]; + char before = content[-1]; + char after = content[sig_length]; - if ( char_is_alphanumeric( after ) || after == '_' ) + if ( char_is_alphanumeric( before ) || before == '_' + || char_is_alphanumeric( after ) || after == '_' ) { continue; } @@ -626,6 +631,7 @@ void refactor() content++; left--; + Skip: continue; } diff --git a/bloat.hpp b/bloat.hpp index f558efb..8d18278 100644 --- a/bloat.hpp +++ b/bloat.hpp @@ -72,7 +72,6 @@ do \ while(0) \ -using c8 = char; using s8 = zpl_i8; using s32 = zpl_i32; using s64 = zpl_i64; @@ -84,7 +83,7 @@ using uw = zpl_usize; using sw = zpl_isize; -ct c8 const* Msg_Invalid_Value = "INVALID VALUE PROVIDED"; +ct char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED"; namespace Memory diff --git a/refactor.cpp b/refactor.cpp index a787ba9..9542439 100644 --- a/refactor.cpp +++ b/refactor.cpp @@ -6,7 +6,6 @@ namespace File { zpl_string Source = nullptr; zpl_string Destination = nullptr; - zpl_file_contents Content {}; zpl_arena Buffer; @@ -92,7 +91,7 @@ namespace Spec } ct - c8 strlen_tok( Tok tok ) + char strlen_tok( Tok tok ) { ct const u8 tok_to_len[ Tok::Num_Tok ] = @@ -632,6 +631,7 @@ void refactor() content++; left--; + Skip: continue; }