Ultimaker / CuraEngine

Powerful, fast and robust engine for converting 3D models into g-code instructions for 3D printers. It is part of the larger open source project Cura.
https://ultimaker.com/en/products/cura-software
GNU Affero General Public License v3.0
1.66k stars 876 forks source link

Add string-switch type and integrate into settings retrieval #1918

Closed jellespijker closed 11 months ago

jellespijker commented 11 months ago

This commit introduces a new type 'string-switch' to handle string comparisons in a switch-case format. This is achieved by employing a DJB2a-based hash function to convert each string to a unique, corresponding enum value. The primary motivation behind this was to refactor the existing settings retrieval process, which was heavily reliant on long if-else constructs. By replacing these with more manageable switch statements, the code readability and maintainability is significantly improved. This change also facilitates the addition of new settings by simply extending existing enums and the related switch statements.

Contributes to CURA-10702

github-actions[bot] commented 11 months ago

Unit Test Results

26 tests  ±0   26 :heavy_check_mark: ±0   14s :stopwatch: +4s   1 suites ±0     0 :zzz: ±0    1 files   ±0     0 :x: ±0 

Results for commit af234bd9. ± Comparison against base commit 535a26d9.

:recycle: This comment has been updated with latest results.