Skip to content

Remove unused code and simplify internal APIs#12

Merged
imakris merged 5 commits intomasterfrom
claude/refactor-code-cleanup-xO5dd
Feb 12, 2026
Merged

Remove unused code and simplify internal APIs#12
imakris merged 5 commits intomasterfrom
claude/refactor-code-cleanup-xO5dd

Conversation

@imakris
Copy link
Owner

@imakris imakris commented Feb 12, 2026

This PR removes unused functions, methods, and internal APIs to reduce code complexity and maintenance burden.

Summary

Significant cleanup of the codebase by removing unused or redundant functionality across multiple modules. This includes removing advanced dispatch methods from the Qt helper library, unused UTF-8 utilities, unnecessary data source methods, and internal metrics tracking.

Key Changes

Qt Safe Dispatch Library (vnm_qt_safe_dispatch.h)

  • Removed safe_invoke() and safe_emit() methods (synchronous/queued hybrid dispatch)
  • Removed blocking_invoke() and try_blocking_invoke() (blocking cross-thread calls)
  • Removed post_emit() and post_emit_batch() (signal emission helpers)
  • Kept only post_invoke() for fire-and-forget method calls
  • Simplified documentation to focus on the remaining functionality
  • Removed unused includes (<QThread>, <exception>, <functional>, <optional>, <stdexcept>)

UTF-8 Utilities (utf8_utils.h/cpp)

  • Removed utf8_decode_one() from public API (kept as internal helper)
  • Removed codepoint_to_utf8() from public API
  • Removed utf8_length(), is_printable(), is_whitespace(), is_digit(), trim(), and split() functions
  • Kept only utf8_to_codepoints() and codepoints_to_utf8() for core conversions

Data Source and Series APIs

  • Removed timestamp() method from function_sample_t
  • Removed generate_with_range() from Function_data_source
  • Removed set_preview_source() and set_preview_source_ref() from series_data_t
  • Removed ensure_preview_config() private helper
  • Removed operator!=() from Size_2i (equality operator remains)

Renderer and Core Components

  • Removed metrics tracking (snapshot_failures counter) from Series_renderer
  • Removed OpenGL status and horizontal label subsecond method detection from Plot_renderer
  • Removed unused member variables from Plot_renderer::impl_t
  • Simplified grid rendering by extracting helper functions
  • Removed override_directory() getter from Asset_loader
  • Removed set_app_name() function from platform paths
  • Removed unused constant k_grid_line_half_px

Algorithm and Layout

  • Simplified choose_lod_level() by removing unused current_level parameter
  • Consolidated platform-specific code paths in platform_paths.cpp

Implementation Details

  • All removals maintain backward compatibility for public-facing APIs that remain
  • Internal refactoring consolidates related functionality (e.g., grid alpha computation)
  • Simplified conditional compilation for platform-specific code
  • Reduced header dependencies by removing unused includes

https://claude.ai/code/session_01AHLB8zcNmNvtTXEa5aMGTP

claude and others added 5 commits February 12, 2026 20:49
Dead code removal:
- types.h: Remove C++20-redundant operator!= on Size_2i and layout_cache_key_t,
  unused set_preview_source/set_preview_source_ref and ensure_preview_config
- constants.h: Remove 4 unused constants (k_grid_line_half_px, k_max_grid_levels,
  k_drawn_x_reserve, k_index_growth_step)
- algo.h: Remove unused current_level parameter from choose_lod_level
- function_sample.h: Remove unused timestamp(), generate_with_range(),
  make_function_sample_policy()
- layout_calculator.h: Remove unused horizontal_finest_step field, merge duplicate
  namespace blocks
- asset_loader: Remove unused override_directory() getter
- series_renderer: Remove write-only metrics_t struct and all metric writes
- vnm_qt_safe_dispatch.h: Remove 6 unused dispatch functions (safe_invoke,
  blocking_invoke, try_blocking_invoke, safe_emit, post_emit, post_emit_batch)
  and all convenience overloads, keeping only post_invoke (839 -> 173 lines)
- utf8_utils: Remove 8 unused functions (utf8_decode_one, codepoint_to_utf8,
  utf8_length, is_printable, is_whitespace, is_digit, trim, split), internalize
  helpers into anonymous namespace
- platform_paths: Remove unused set_app_name/get_app_name, make s_app_name constexpr

Deduplication:
- chrome_renderer.cpp: Extract compute_grid_alpha() and append_grid_level() helpers,
  merge duplicate tick level builders into single generic lambda
- range_cache.h: Merge validate_preview_range_cache_sequences into
  validate_range_cache_sequences with preview parameter
- types.h: Add skip_gl and dark_mode to frame_context_t, eliminating 14 repeated
  config extractions across chrome_renderer, series_renderer, and text_renderer
- platform_paths.cpp: Merge duplicate get_home_directory() for macOS/Linux

https://claude.ai/code/session_01AHLB8zcNmNvtTXEa5aMGTP
The notify_opengl_status and notify_hlabels_subsecond lambdas dispatched
to set_opengl_status_from_renderer(int) and
set_hlabels_subsecond_from_renderer(bool) via string-based invokeMethod,
but neither method exists on Plot_widget or any subclass in the codebase.
The runtime indexOfMethod checks always returned false, making the
dispatch calls unreachable dead code.

Removes: two lambda definitions, five call sites, three bool flags
(methods_checked, has_opengl_status_method, has_hlabels_subsecond_method),
and three int fields (init_failed_status, last_opengl_status,
last_hlabels_subsecond) from impl_t.

Incorporated from branch claude/review-safe-dispatch-usage-omVTs.

https://claude.ai/code/session_01AHLB8zcNmNvtTXEa5aMGTP
@imakris imakris merged commit ad2a3f9 into master Feb 12, 2026
@imakris imakris deleted the claude/refactor-code-cleanup-xO5dd branch February 12, 2026 22:33
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.

2 participants