Skip to content

Conversation

@iphydf
Copy link
Member

@iphydf iphydf commented Feb 14, 2024

Please review very carefully. This should make the function O(n) instead of O(n^2).


This change is Reviewable

@iphydf iphydf added this to the v0.2.20 milestone Feb 14, 2024
@codecov
Copy link

codecov bot commented Feb 14, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.09%. Comparing base (7cefa93) to head (0cf065c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2688      +/-   ##
==========================================
+ Coverage   72.06%   72.09%   +0.02%     
==========================================
  Files         159      159              
  Lines       31305    31309       +4     
==========================================
+ Hits        22561    22571      +10     
+ Misses       8744     8738       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@iphydf iphydf force-pushed the nonrec-add_to_list branch from a20503f to ef2ff3c Compare February 28, 2024 16:15
@iphydf iphydf modified the milestones: v0.2.20, v0.2.21 Mar 28, 2024
@iphydf iphydf force-pushed the nonrec-add_to_list branch from ef2ff3c to c185481 Compare November 8, 2024 14:25
@github-actions github-actions bot added the refactor Refactoring production code, eg. renaming a variable, not affecting semantics label Nov 8, 2024
@iphydf iphydf force-pushed the nonrec-add_to_list branch from c185481 to fffc249 Compare November 30, 2024 01:08
@iphydf iphydf marked this pull request as ready for review November 30, 2024 01:09
@iphydf iphydf force-pushed the nonrec-add_to_list branch from fffc249 to f74d996 Compare December 2, 2024 10:46
@iphydf iphydf modified the milestones: v0.2.21, v0.2.22 Jan 24, 2025
@iphydf iphydf force-pushed the nonrec-add_to_list branch from f74d996 to 899e461 Compare February 8, 2025 11:42
@iphydf iphydf force-pushed the nonrec-add_to_list branch from 899e461 to 33439d7 Compare October 18, 2025 22:40
@iphydf iphydf force-pushed the nonrec-add_to_list branch 3 times, most recently from 0cf065c to 3addb04 Compare November 3, 2025 00:18
@Green-Sky
Copy link
Member

One of the call sites also has this comment:

c-toxcore/toxcore/DHT.c

Lines 682 to 684 in 206ea35

// TODO(zugz): this could be made significantly more efficient by
// using a version of add_to_list which works with a sorted list.
add_to_list(nodes_list, MAX_SENT_NODES, client->public_key, &ipptp->ip_port, public_key);

@iphydf iphydf force-pushed the nonrec-add_to_list branch from 3addb04 to e115b13 Compare November 5, 2025 01:18
@iphydf
Copy link
Member Author

iphydf commented Nov 5, 2025

One of the call sites also has this comment:

c-toxcore/toxcore/DHT.c

Lines 682 to 684 in 206ea35

// TODO(zugz): this could be made significantly more efficient by
// using a version of add_to_list which works with a sorted list.
add_to_list(nodes_list, MAX_SENT_NODES, client->public_key, &ipptp->ip_port, public_key);

That would make it O(log n). We're faster now, because it's O(n), but we could be even faster.

@Green-Sky
Copy link
Member

One of the call sites also has this comment:

c-toxcore/toxcore/DHT.c

Lines 682 to 684 in 206ea35

// TODO(zugz): this could be made significantly more efficient by
// using a version of add_to_list which works with a sorted list.
add_to_list(nodes_list, MAX_SENT_NODES, client->public_key, &ipptp->ip_port, public_key);

That would make it O(log n). We're faster now, because it's O(n), but we could be even faster.

Hmm right. Let's just leave the TODO as is then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring production code, eg. renaming a variable, not affecting semantics

Development

Successfully merging this pull request may close these issues.

2 participants