Skip to content

Improve median macro#325

Open
immrsd wants to merge 1 commit into
feat/medianfrom
feat/mediam-improvements
Open

Improve median macro#325
immrsd wants to merge 1 commit into
feat/medianfrom
feat/mediam-improvements

Conversation

@immrsd
Copy link
Copy Markdown
Collaborator

@immrsd immrsd commented May 21, 2026

Problem

vector::median! is a macro, so every integrator call site inlines the full quick_sort_by! body (~125 lines of bytecode) plus macros::average!'s u256 machinery. The PR #135 test module already had to add wrapper functions to stay under Sui's per-module bytecode limit at ~50 call sites — integrators using median! for two widths in one module would hit the same limit with no documented reason.

Changes

  • Move the sort + average expansions into a shared public(package) fun median_u256 so they're paid once in the package instead of at every call site. The public median! macro is now a thin upcast → delegate → downcast wrapper
  • Switch the empty-vector contract from option::none() to abort(EEmptyVector), matching the package's convention for undefined-domain inputs (EDivideByZero, EZeroModulus). Return type drops from Option<$Int> to $Int

@immrsd immrsd self-assigned this May 21, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b649193d-0e87-415e-8749-d97e3535b4f8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mediam-improvements

Comment @coderabbitai help to get the list of available commands and usage tips.

@immrsd immrsd requested a review from qalisander May 21, 2026 19:07
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