paradigmxyz / cryo

cryo is the easiest way to extract blockchain data to parquet, csv, json, or python dataframes
Apache License 2.0
1.12k stars 97 forks source link

refactor: streamlining `DimIsNone` trait and optimizing `parse_u256_types` #153

Closed codeesura closed 8 months ago

codeesura commented 8 months ago

Motivation

The primary goal of these changes is to enhance the readability and efficiency of the code in the Args struct. In its previous state, certain functions like dim_is_none and parse_u256_types were more verbose than necessary and did not fully leverage Rust's expressive capabilities. By refactoring these functions, we aim to make the codebase cleaner, more maintainable, and easier for other contributors to understand and work with.

Solution

  1. DimIsNone Trait Refactoring:

    • Simplified the dim_is_none function by returning the negation of dim_is_some, thereby removing redundant match statements.
  2. parse_u256_types Function Optimization:

    • Refactored to use map_or and map for more idiomatic and streamlined logic.
    • Consolidated string comparisons in pattern matching to improve performance and readability.

These changes maintain the existing functionality while significantly enhancing code quality.