Revision 1.236 by

Revision 1.237 by

… | … | ||
---|---|---|---|

768 | * the difference is about 5% with 50000+ watchers. | 768 | * the difference is about 5% with 50000+ watchers. |

769 | */ | 769 | */ |

770 | #define USE_4HEAP !EV_MINIMAL | 770 | #define USE_4HEAP !EV_MINIMAL |

771 | #if USE_4HEAP | 771 | #if USE_4HEAP |

772 | 772 | ||

773 | #define DHEAP 4 | ||

773 | #define HEAP0 3 /* index of first element in heap */ | 774 | #define HEAP0 (DHEAP - 1) /* index of first element in heap */ |

774 | 775 | ||

775 | /* towards the root */ | 776 | /* towards the root */ |

776 | void inline_speed | 777 | void inline_speed |

777 | upheap (WT *heap, int k) | 778 | upheap (WT *heap, int k) |

778 | { | 779 | { |

779 | WT w = heap [k]; | 780 | WT w = heap [k]; |

780 | 781 | ||

781 | for (;;) | 782 | for (;;) |

782 | { | 783 | { |

783 | int p = ((k - HEAP0 - 1) / 4) + HEAP0; | 784 | int p = ((k - HEAP0 - 1) / DHEAP) + HEAP0; |

784 | 785 | ||

785 | if (p >= HEAP0 || heap [p]->at <= w->at) | 786 | if (p >= HEAP0 || heap [p]->at <= w->at) |

786 | break; | 787 | break; |

787 | 788 | ||

788 | heap [k] = heap [p]; | 789 | heap [k] = heap [p]; |

… | … | ||

803 | 804 | ||

804 | for (;;) | 805 | for (;;) |

805 | { | 806 | { |

806 | ev_tstamp minat; | 807 | ev_tstamp minat; |

807 | WT *minpos; | 808 | WT *minpos; |

808 | WT *pos = heap + 4 * (k - HEAP0) + HEAP0; | 809 | WT *pos = heap + DHEAP * (k - HEAP0) + HEAP0; |

809 | 810 | ||

810 | // find minimum child | 811 | // find minimum child |

811 | if (expect_true (pos +3 < E)) | 812 | if (expect_true (pos + DHEAP - 1 < E)) |

812 | { | 813 | { |

813 | /* fast path */ | 814 | /* fast path */ |

814 | (minpos = pos + 0), (minat = (*minpos)->at); | 815 | (minpos = pos + 0), (minat = (*minpos)->at); |

815 | if (pos [1]->at < minat) (minpos = pos + 1), (minat = (*minpos)->at); | 816 | if (pos [1]->at < minat) (minpos = pos + 1), (minat = (*minpos)->at); |

816 | if (pos [2]->at < minat) (minpos = pos + 2), (minat = (*minpos)->at); | 817 | if (pos [2]->at < minat) (minpos = pos + 2), (minat = (*minpos)->at); |

– |
Removed lines |

+ |
Added lines |

< |
Changed lines |

> |
Changed lines |