Skip to content

Marian Becher

My feedback

5 results found

  1. 1 vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    Marian Becher shared this idea  · 
  2. 19 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    An error occurred while saving the comment
    Marian Becher commented  · 

    As already mentioned by others the indexed access into a typed collection (`doc.pageItems[i]`, `layer.pathItems[i]`, …) is not O(1). The cost of a single `[i]` grows with `i`. So the obvious forward loop over a whole collection is O(N²) and becomes unusable on large documents.

    My Environment:
    Illustrator `30.3`, Windows, ExtendScript / CEP.

    The workaround I'm using:
    since `uuid` / `Document.getPageItemFromUuid()` were added (~v24 / 2020), and UUIDs appear to be handed out as sequential integers, I can ignore the collection and walk by UUID. `getPageItemFromUuid(String(n))` appears to be O(1), so the traversal is O(N):

    Example Code:
    (function () {
    var doc = app.activeDocument;
    var expected = doc.pageItems.length; // target count
    var HARD_CAP = 268435456; // 2^28 safety net
    var t0 = new Date().getTime(), yielded = 0, cursor = 0;

    while (yielded < expected && cursor < HARD_CAP) {
    var item = null;
    try { item = doc.getPageItemFromUuid(String(cursor)); } catch (e) {}
    cursor++;
    if (item == null) continue; // empty / deleted slot
    // ...do work with `item`...
    // Note: I had to add additional test to filter out items from other documents as well as well as Layers etc...
    yielded++;
    }
    $.writeln("UUID walk: " + yielded + " items in " +
    ((new Date().getTime() - t0) / 1000) + "s (cursor=" + cursor + ")");
    })();

    1. Is there an official, supported O(N) way to enumerate every `PageItem` at any depth that I've missed?
    2. Is the sequential-integer-UUID walk safe to rely on, or is it an implementation detail that can break — non-zero-based ranges, gaps beyond plain deletions, non-integer UUIDs after edits/undo/redo, copy-paste between docs? Today I skip empty slots, stop at `pageItems.length`, and cap the cursor.

    Caveat others may hit: `getPageItemFromUuid` returns items from other open and even closed documents (UUIDs are app-global). I filter by walking `.parent` up to the owning `Document` and comparing.

    Marian Becher supported this idea  · 
  3. 86 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    Marian Becher supported this idea  · 
  4. 25 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    Marian Becher supported this idea  · 
  5. 7 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    Marian Becher supported this idea  ·