Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup static variables #211

Open
zufuliu opened this issue May 12, 2024 · 1 comment
Open

Cleanup static variables #211

zufuliu opened this issue May 12, 2024 · 1 comment

Comments

@zufuliu
Copy link

zufuliu commented May 12, 2024

  1. static const int hash_value_mask can be changed to static constexpr int hash_value_mask:

    static const int hash_value_mask = 1 << (std::numeric_limits<int>::digits - 1);

  2. static on trivial w and s variables can be removed:

    static const charT w = 'w';
    static const charT s = 's';

  3. static const std::uintmax_t one can be changed to constexpr std::uintmax_t one:

    static const std::uintmax_t one = 1uL;

    static const std::uintmax_t one = 1uL;

  4. static const char incomplete_message[] can be changed to const char * const incomplete_message:

    static const char incomplete_message[] = "Incomplete \\g escape found.";

    static const char incomplete_message[] = "Missing } in quantified repetition.";

    static const char incomplete_message[] = "Character set declaration starting with [ terminated prematurely - either no ] was found or the set had no content.";

    static const char incomplete_message[] = "Character class declaration starting with [ terminated prematurely - either no ] was found or the set had no content.";

  5. static const bool value can be changed to static constexpr bool value:

    static const bool value = (std::is_convertible<cat*, std::random_access_iterator_tag*>::value);

    static const bool value = true;

    static const bool value = answer::value;

  6. const bool is_random_access_iterator can be changed to constexpr bool is_random_access_iterator:

    const bool is_random_access_iterator<I>::value;

    these two lines can be removed after change line 75 to constexpr.

  7. static const std::ptrdiff_t k can be changed to constexpr std::ptrdiff_t k:

    static const std::ptrdiff_t k = 100000;

  8. static const bool value can be changed to static constexpr bool value:

    static const bool value = sizeof(checker(get())) > 1;

  9. big array const char* messages[] can be marked as static:

    const char* messages[] = {

  10. big array char_syntax[] can be marked as const:

    static regex_constants::syntax_type char_syntax[] = {

    static regex_constants::escape_syntax_type char_syntax[] = {

  11. big array combining_ranges[] can be marked as static:

    const std::uint_least16_t combining_ranges[] = { 0x0300, 0x0361,

  12. static const for trivial variables can be changed to constexpr:

    static const charT zero = '0';
    static const charT nine = '9';
    static const charT a = 'a';
    static const charT f = 'f';
    static const charT A = 'A';
    static const charT F = 'F';

  13. static const char_class_type can be change to static constexpr char_class_type:

    static const char_class_type mask_word = 0x0400; // must be C1_DEFINED << 1
    static const char_class_type mask_unicode = 0x0800; // must be C1_DEFINED << 2
    static const char_class_type mask_horizontal = 0x1000; // must be C1_DEFINED << 3
    static const char_class_type mask_vertical = 0x2000; // must be C1_DEFINED << 4
    static const char_class_type mask_base = 0x3ff; // all the masks used by the CT_CTYPE1 group

  14. static const string_type null_string; can be changed to constexpr string_type null_string; const string_type null_string;:

    static const string_type null_string;

zufuliu added a commit to zufuliu/notepad4 that referenced this issue May 12, 2024
@zufuliu
Copy link
Author

zufuliu commented May 12, 2024

With these changes, Notepad2 built by MSVC is 1KB~2KB smaller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant