Explorar o código

refactor & feat: Code只在Debug模式下编译display

SongZihuan %!s(int64=3) %!d(string=hai) anos
pai
achega
b5ecd4137e
Modificáronse 3 ficheiros con 12 adicións e 4 borrados
  1. 8 2
      include/core/code.h
  2. 0 2
      include/core/msg.inline.h
  3. 4 0
      src/core/code.cpp

+ 8 - 2
include/core/code.h

@@ -12,11 +12,14 @@ namespace aFuncore {
         ~Code();
         Code &operator=(const Code &)=delete;
 
-        void display() const;
         [[nodiscard]] std::string getMD5_v1() const;
         bool writeByteCode(const aFuntool::FilePath &file_path, bool debug=false) const;  // NOLINT 允许忽略返回值
         bool readByteCode(const aFuntool::FilePath &file_path);
 
+#ifdef aFunDEBUG
+        void display() const;
+#endif
+
         [[nodiscard]] inline const aFuntool::FilePath &getFilePath() const;
         [[nodiscard]] inline ByteCode *getByteCode() const;
     private:
@@ -48,11 +51,14 @@ namespace aFuncore {
         ByteCode &operator=(const ByteCode &)=delete;
 
         ByteCode *connect(ByteCode *new_code);
-        void display() const;
         bool write_v1(FILE *f, bool debug=false) const;
         ByteCode *read_v1(FILE *f, bool debug=false, int8_t read_type=code_element, bool to_son=false);
         [[nodiscard]] std::string getMD5_v1() const;
 
+#ifdef aFunDEBUG
+        void display() const;
+#endif
+
         [[nodiscard]] CodeType getType() const;
         [[nodiscard]] char getPrefix() const;
 

+ 0 - 2
include/core/msg.inline.h

@@ -1,7 +1,5 @@
 #ifndef AFUN_MSG_INLINE_H
 #define AFUN_MSG_INLINE_H
-#include <utility>
-
 #include "msg.h"
 
 namespace aFuncore {

+ 4 - 0
src/core/code.cpp

@@ -23,6 +23,7 @@ namespace aFuncore {
         delete code;
     }
 
+#ifdef aFunDEBUG
     /**
      * 显式自己以及其子、兄代码块
      */
@@ -51,6 +52,7 @@ namespace aFuncore {
                 tmp = tmp->next;
         }
     }
+#endif
 
 #define Done(write) do{if(!(write)){return false;}}while(0)
     /**
@@ -364,6 +366,7 @@ RETURN_FALSE:
         return new_code;
     }
 
+#ifdef aFunDEBUG
     /**
      * 显式代码块内容
      */
@@ -376,6 +379,7 @@ RETURN_FALSE:
         else
             aFuntool::cout << "\n";
     }
+#endif
 
 #define Done(write) do{if(!(write)){return false;}}while(0)