Refactor Web3Wrapper and optimize string/array operations#2
Open
Kushmanmb wants to merge 24 commits intoFoboz:masterfrom
Open
Refactor Web3Wrapper and optimize string/array operations#2Kushmanmb wants to merge 24 commits intoFoboz:masterfrom
Kushmanmb wants to merge 24 commits intoFoboz:masterfrom
Conversation
- Extract hex prefix stripping duplication in NSString+HexToDecimal.swift to use existing stripHexPrefix() method - Extract keydata decryption pattern into obtainDecryptedKeydata() helper method (used in 3 places) - Extract BIP32Keystore creation pattern into createBIP32Keystore() helper method (used in 2 places) Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
The condition `bip32Keystore != nil` is redundant since `try?` already returns `nil` on failure Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
- Fix O(n²) string indexing in String+RandSeed (use enumerated() instead of repeated index()) - Optimize Array+UInt32 rand() to avoid O(n) remove/append pattern - Remove unnecessary String allocation in Character+ASCIIValue - Pre-allocate array capacities in UIColor+RandSeed and Web3Wrapper - Add performance comments explaining optimizations Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
- Fix incorrect O(1) claim in Array+UInt32 comment (still O(n) but avoids reallocation) - Extract magic number 3 to named constant colorCount in UIColor+RandSeed Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
- Use force unwrap in Character.asciiValue (every Character has at least one unicode scalar) - Remove empty array guard in Array.rand() to preserve original crash behavior on misuse Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
…ency Optimize performance bottlenecks in utility extensions
Refactor duplicated code patterns in Web3Wrapper and NSString extensions
Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
Kushmanmb
commented
Jan 17, 2026
Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
…eToJSON Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
Refactor duplicated code patterns in Web3Wrapper and CheckboxButton
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves code quality, readability, and performance across several core components of the MEWconnect iOS app. This PR focuses on refactoring repeated code patterns, optimizing string/array operations, and modernizing project configuration files.
🎯 Motivation
📝 Changes
🔧 Refactoring (Web3Wrapper. swift)
Problem: Keydata decryption logic was duplicated across 3 methods
Solution: Extracted into reusable helper methods
obtainDecryptedKeydata(): Centralized repeated 2-line decryption patterncreateBIP32Keystore(): Static helper for BIP32 keystore creation!) operators for safer optional handlingImpact:
⚡ Performance Optimizations
Character+ASCIIValue. swift
Before: Created intermediate String object
After: Direct unicode scalar access