Skip to content

Develop - #2

Merged
caomengxuan666 merged 2 commits into
mainfrom
develop
Feb 12, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
develop

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member
  • Add complete safePrint overload set in utils:console module:

    • safePrint(const wchar_t*) - zero-cost wide string output
    • safePrint(char) - single character output
    • safePrint(const char*) - C string output
    • safePrint(std::string_view) - zero-copy string view output
    • safePrint(int/unsigned/long/long long) - integer formatting output
    • safePrint(bool) - boolean output
    • safePrint(const void*) - pointer output
    • Corresponding overloads for safeErrorPrint
    • Corresponding overloads for safePrintLn/safeErrorPrintLn
  • Completely eliminate high-cost operations in all commands:

    • Remove all std::wostringstream instantiations (save 8.6KB each)
    • Remove all std::wstring(1, c) constructions (save 1.2KB each)
    • Remove all L"^" + std::wstring concatenations (save 2.4KB each)
    • Remove all std::string(a + b + c) chained concatenations
    • Replace with snprintf + std::string_view stack formatting
  • Optimize specific command implementations:

    • cat.cppm: completely rewrite character processing logic, STL overhead 38KB → 20KB
    • ls.cppm: permission string wstring → string, size formatting wostringstream → snprintf
    • cp.cppm/mv.cppm: remove operator+ path concatenation, use operator+=
    • echo.cppm: simplify output logic, remove temporary wstring
    • rm.cppm/wc.cppm/mkdir.cppm: unify to use safePrint overload set
  • Infrastructure improvements:

    • Add src/pch/string_instances.h/cpp for explicit std::string/std::wstring instantiations
    • Add string_instances.cpp to CMakeLists.txt for both winuxcmd and command macro
    • Include string_instances.h in pch.h for shared instantiation declarations across all modules
  • Documentation:

    • Add "High-Performance C++23 Coding Guidelines" section in CONTRIBUTING.md
    • Add Chinese version CONTRIBUTING_ZH.MD with detailed string handling best practices
    • Provide string type selection guide with recommended/cautious/prohibited categories
    • Add code templates for file size formatting, time formatting, path building
    • Add cost comparison table for different string operations
    • Update website links in README-zh.md and README.md to product links

Performance improvements:

  • Total executable size: 477KB → 428KB (↓49KB)
  • ls.cpp.obj: 53.75KB → 38.95KB (↓14.8KB)
  • cat.cpp.obj: 35.11KB → 28.44KB (↓6.67KB)
  • echo.cpp.obj: 19.80KB → 14.03KB (↓5.77KB)
  • cp.cpp.obj: 25.04KB → 22.76KB (↓2.28KB)
  • rm.cpp.obj: 16.43KB → 14.41KB (↓2.02KB)
  • stl_string overhead: 146KB → 129KB (↓17KB)
  • string_instances.cpp.obj: 15.07KB → 12.53KB (↓2.54KB)

- Add CMake policy settings to suppress warnings
- Add GENERATE_MAP_INFO option for generating map information
- Bump project version from 0.1.4 to 0.2.0
- Update command source file collection from .cppm to .cpp
- Add static CRT compilation option configuration
- Configure link options to generate map files

docs: add contribution guidelines and test framework documentation

- Create CONTRIBUTING.md containing development workflow and code style guidelines
- Add test framework documentation (English and Chinese versions)
- Update documentation links in README to point to new documents

chore: update .gitignore and clean up Linux help documentation

- Add /testing directory to ignore list
- Remove help documentation files for multiple Linux commands
- Update supported parameter list for ls command (-n, --color)
…g handling across all commands

- Add complete safePrint overload set in utils:console module:
  * safePrint(const wchar_t*) - zero-cost wide string output
  * safePrint(char) - single character output
  * safePrint(const char*) - C string output
  * safePrint(std::string_view) - zero-copy string view output
  * safePrint(int/unsigned/long/long long) - integer formatting output
  * safePrint(bool) - boolean output
  * safePrint(const void*) - pointer output
  * Corresponding overloads for safeErrorPrint
  * Corresponding overloads for safePrintLn/safeErrorPrintLn

- Completely eliminate high-cost operations in all commands:
  * Remove all std::wostringstream instantiations (save 8.6KB each)
  * Remove all std::wstring(1, c) constructions (save 1.2KB each)
  * Remove all L"^" + std::wstring concatenations (save 2.4KB each)
  * Remove all std::string(a + b + c) chained concatenations
  * Replace with snprintf + std::string_view stack formatting

- Optimize specific command implementations:
  * cat.cppm: completely rewrite character processing logic, STL overhead 38KB → 20KB
  * ls.cppm: permission string wstring → string, size formatting wostringstream → snprintf
  * cp.cppm/mv.cppm: remove operator+ path concatenation, use operator+=
  * echo.cppm: simplify output logic, remove temporary wstring
  * rm.cppm/wc.cppm/mkdir.cppm: unify to use safePrint overload set

- Infrastructure improvements:
  * Add src/pch/string_instances.h/cpp for explicit std::string/std::wstring instantiations
  * Add string_instances.cpp to CMakeLists.txt for both winuxcmd and command macro
  * Include string_instances.h in pch.h for shared instantiation declarations across all modules

- Documentation:
  * Add "High-Performance C++23 Coding Guidelines" section in CONTRIBUTING.md
  * Add Chinese version CONTRIBUTING_ZH.MD with detailed string handling best practices
  * Provide string type selection guide with recommended/cautious/prohibited categories
  * Add code templates for file size formatting, time formatting, path building
  * Add cost comparison table for different string operations
  * Update website links in README-zh.md and README.md to product links

Performance improvements:
  * Total executable size: 477KB → 428KB (↓49KB)
  * ls.cpp.obj: 53.75KB → 38.95KB (↓14.8KB)
  * cat.cpp.obj: 35.11KB → 28.44KB (↓6.67KB)
  * echo.cpp.obj: 19.80KB → 14.03KB (↓5.77KB)
  * cp.cpp.obj: 25.04KB → 22.76KB (↓2.28KB)
  * rm.cpp.obj: 16.43KB → 14.41KB (↓2.02KB)
  * stl_string overhead: 146KB → 129KB (↓17KB)
  * string_instances.cpp.obj: 15.07KB → 12.53KB (↓2.54KB)
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

Successfully merging this pull request may close these issues.

1 participant