~ubuntu-branches/ubuntu/wily/zeromq3/wily-proposed

« back to all changes in this revision

Viewing changes to src/mtrie.cpp

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2014-03-16 14:02:28 UTC
  • mfrom: (1.1.6) (6.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140316140228-ig1sgh7czk59m9ux
Tags: 4.0.4+dfsg-1
* QA upload; orphan the package
  - Upload to unstable
* New upstream release
* Update repack.stub script
* Drop 02_fix-exported-symbols.patch and 03_fix-s390-rdtsc.patch
  (merged upstream)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    Copyright (c) 2011 250bpm s.r.o.
3
 
    Copyright (c) 2011-2012 Spotify AB
4
 
    Copyright (c) 2011 Other contributors as noted in the AUTHORS file
 
2
    Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
5
3
 
6
4
    This file is part of 0MQ.
7
5
 
53
51
        delete next.node;
54
52
        next.node = 0;
55
53
    }
56
 
    else if (count > 1) {
 
54
    else 
 
55
    if (count > 1) {
57
56
        for (unsigned short i = 0; i != count; ++i)
58
 
            if (next.table [i])
59
 
                delete next.table [i];
 
57
            delete next.table [i];
60
58
        free (next.table);
61
59
    }
62
60
}
90
88
            count = 1;
91
89
            next.node = NULL;
92
90
        }
93
 
        else if (count == 1) {
 
91
        else 
 
92
        if (count == 1) {
94
93
            unsigned char oldc = min;
95
94
            mtrie_t *oldp = next.node;
96
95
            count = (min < c ? c - min : min - c) + 1;
102
101
            min = std::min (min, c);
103
102
            next.table [oldc - min] = oldp;
104
103
        }
105
 
        else if (min < c) {
106
 
 
 
104
        else 
 
105
        if (min < c) {
107
106
            //  The new character is above the current character range.
108
107
            unsigned short old_count = count;
109
108
            count = c - min + 1;
114
113
                next.table [i] = NULL;
115
114
        }
116
115
        else {
117
 
 
118
116
            //  The new character is below the current character range.
119
117
            unsigned short old_count = count;
120
118
            count = (min + old_count) - c;
244
242
        count = 0;
245
243
    }
246
244
    //  Compact the node table if possible
247
 
    else if (live_nodes == 1) {
 
245
    else 
 
246
    if (live_nodes == 1) {
248
247
        //  If there's only one live node in the table we can
249
248
        //  switch to using the more compact single-node
250
249
        //  representation
257
256
        count = 1;
258
257
        min = new_min;
259
258
    }
260
 
    else if (new_min > min || new_max < min + count - 1) {
 
259
    else
 
260
    if (new_min > min || new_max < min + count - 1) {
261
261
        zmq_assert (new_max - new_min + 1 > 1);
262
262
 
263
263
        mtrie_t **old_table = next.table;
342
342
                free (next.table);
343
343
                next.node = oldp;
344
344
            }
345
 
            else if (c == min) {
 
345
            else
 
346
            if (c == min) {
346
347
                //  We can compact the table "from the left"
347
348
                unsigned short i;
348
349
                for (i = 1; i < count; ++i)
358
359
                memmove (next.table, old_table + i, sizeof (mtrie_t*) * count);
359
360
                free (old_table);
360
361
            }
361
 
            else if (c == min + count - 1) {
 
362
            else
 
363
            if (c == min + count - 1) {
362
364
                //  We can compact the table "from the right"
363
365
                unsigned short i;
364
366
                for (i = 1; i < count; ++i)