Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

1.2.x #5

Closed
wants to merge 2 commits into from

3 participants

@peter-ryan

avoid a potentially expensive count call when an empty check will suffice

osi and others added some commits
@osi osi GC tuning for agents
Don't call count, which can be expensive. Just peek and if its not null, treat that
as being > 0
16d2688
Peter Ryan avoid a potentially expensive count call when an empty check will suf…
…fice
4bd91b3
@hiredman

clojure doesn't accept pull requests, please check out the contributing section of clojure.org

@Tirael90 Tirael90 referenced this pull request in clojure-android/clojure
Closed

Android 5.0 - L #3

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 29, 2010
  1. @osi

    GC tuning for agents

    osi authored
    Don't call count, which can be expensive. Just peek and if its not null, treat that
    as being > 0
Commits on Feb 16, 2011
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/jvm/clojure/lang/Agent.java
View
10 src/jvm/clojure/lang/Agent.java
@@ -136,8 +136,12 @@ static void doRun(Action action){
popped = action.agent.aq.compareAndSet(prior, next);
}
- if(error == null && next.q.count() > 0)
- ((Action) next.q.peek()).execute();
+ if(error == null) {
+ Action nextAction = (Action) next.q.peek();
+ if (null != nextAction) {
+ nextAction.execute();
+ }
+ }
}
finally
{
@@ -251,7 +255,7 @@ void enqueue(Action action){
queued = aq.compareAndSet(prior, new ActionQueue((IPersistentStack)prior.q.cons(action), prior.error));
}
- if(prior.q.count() == 0 && prior.error == null)
+ if(prior.q.peek() == null && prior.error == null)
action.execute();
}
Something went wrong with that request. Please try again.