GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Simplify ASCII check with Java < 11 · Issue #637 · smallrye/jandex

Simplify ASCII check with Java < 11 #637

New issue
Copy link
New issue
Copy link
Closed
#638
Closed
Simplify ASCII check with Java < 11#637
#638
Copy link

Description

@franz1981
franz1981
opened on Dec 29, 2025
Issue body actions

jandex/core/src/main/java/org/jboss/jandex/BitTricks.java

Line 5 in dd66d77

static boolean isAsciiOnly(byte[] chars, int off, int len) {
doesn't need to perform that much math but can just use a straight loop and check for negative values in order to allow the JIT to unroll the checks to the maximum factor (8 or 16) since the most of the time the branches are not taken.
The additional maths operations performed (to aggregate and mask 8 bytes at once) usually won't pay off for unlikely conditions (assuming low branch misses there) and 8/16 cmp + jump should be very cheap on well predicted branches.
Now the only thing to be careful with is what happen with different compilation levels others than Tier 4, but JMH allows to verify it with ease.

I have fixed a similar performance issue at netty/netty#16030 and should be easy to verify via JMH.

@Ladicek

Activity

  1. Ladicek commented on Jan 2, 2026

    @Ladicek
    Ladicek
    on Jan 2, 2026
    Member
    More actions

    Are you suggesting to simplify the isAsciiOnly() method only for Java < 11 (and keep the existing 11+ implementation intact), or to simplify always?

  2. franz1981 commented on Jan 2, 2026

    @franz1981
    franz1981
    on Jan 2, 2026
    ContributorAuthor
    More actions

    Just for Java < 11 If we care about it.
    The Java 11 one reading 8 bytes in one go is just better ^^

  3. Ladicek commented on Jan 2, 2026

    @Ladicek
    Ladicek
    on Jan 2, 2026
    Member
    More actions

    Gotcha, understood. I'll take a look.

  4. Ladicek commented on Jan 5, 2026

    @Ladicek
    Ladicek
    on Jan 5, 2026
    Member
    More actions

    This is actually not easy to measure, and it looks like the differences are strongly reliant on the length of the string (see the benchmark I added in #638). But I don't think Java 8 is used very often today, so I don't think it's a big deal.

  5. Ladicek
    closed this as completedin #638on Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.