DRAFT: Implement IntRangeSet class to be used for IMAP ActiveSync#26
Draft
amulet1 wants to merge 3 commits into
Draft
DRAFT: Implement IntRangeSet class to be used for IMAP ActiveSync#26amulet1 wants to merge 3 commits into
amulet1 wants to merge 3 commits into
Conversation
Added tests.php and benchmark.php (yes, I know they do not belong here, but this is a draft)
Member
|
This looks promising. Let's sync with Torben when it's in "ready for review" state. |
…ated lookups Fast-append path in addRange for sorted input O(m+n) two-pointer sweeps for union, subtract, intersect, diff String initialization via constructor
TDannhauer
approved these changes
Apr 9, 2026
Member
|
@amulet1 This looks pretty good already - do you feel it is ready? |
Member
Author
|
It still cannot be incorporated directly into any existing code without some serious changes in IMAP client, Activesync and possible in the Core. I am slowly (not enough time) studying the existing code to see how to fit it better. Plugging it here and there without overall redesign, just to have it, makes little sense. |
Contributor
|
@amulet1 what is your proposal to continue with? |
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.
I would like to rework some internals related to how Horde handles IMAP sync.
As this point it is just to introduce a class that could be used to work with UIDs effectively by storing them as sorted array of non-overlaping pairs like these: [start1, end1, start2, end2, ... ].
Based on my preliminary tests it would significantly outperform most array-based operations that are currently used, both memory- and speed-wise. The class is based on my work for an unrelated project.
The class is obviously will be further enhanced/reworked, and moved to the right place. So for how this is just a draft.
The class could be used for servers without MODSEQ too. For that we would have to keep flags differently - instead of keeping flags by UID/type like
$flags[$uid]['read'], we would keep separate flags as instance of the IntRangeSet class with UIDs for which the flag is set, e.g.The class implements several optimized methods that should be helpful for syncing IMAP folders via Activesync:
contains- uses binary search to locate specific UIDunion- add elements of another set to the current setintersect- keep elements that belong to current and another setsubtract- remove elements from set that exist in another set.diff(static, optimized) - compares set A with B and returns 3 sets in a single pass: added, unchanged, removed__toString- returns IMAP message sequence stringfromString- parses IMAP message sequence stringAs the first step, the
Horde_ActiveSync_Folder_Imapshould be updated to use the new class.Other potential uses: replace/improve
Horde_Imap_Client_Idsclass.