ox 2.14.14 → 2.14.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +1 -1
- data/ext/ox/attr.h +33 -39
- data/ext/ox/base64.c +48 -42
- data/ext/ox/base64.h +4 -4
- data/ext/ox/buf.h +80 -86
- data/ext/ox/builder.c +377 -456
- data/ext/ox/cache.c +2 -2
- data/ext/ox/cache8.c +37 -40
- data/ext/ox/cache8.h +7 -7
- data/ext/ox/dump.c +811 -889
- data/ext/ox/err.c +16 -13
- data/ext/ox/err.h +11 -12
- data/ext/ox/extconf.rb +5 -10
- data/ext/ox/gen_load.c +135 -139
- data/ext/ox/hash_load.c +130 -148
- data/ext/ox/helper.h +32 -39
- data/ext/ox/intern.c +1 -2
- data/ext/ox/obj_load.c +586 -662
- data/ext/ox/ox.c +93 -132
- data/ext/ox/ox.h +5 -10
- data/ext/ox/parse.c +836 -874
- data/ext/ox/sax.c +56 -31
- data/ext/ox/sax.h +2 -2
- data/ext/ox/sax_as.c +78 -102
- data/ext/ox/sax_buf.c +85 -94
- data/ext/ox/sax_buf.h +101 -120
- data/ext/ox/sax_hint.c +175 -184
- data/ext/ox/sax_hint.h +19 -19
- data/ext/ox/sax_stack.h +59 -45
- data/ext/ox/slotcache.c +3 -3
- data/ext/ox/slotcache.h +4 -4
- data/ext/ox/special.c +320 -327
- data/ext/ox/special.h +2 -2
- data/ext/ox/type.h +19 -19
- data/lib/ox/bag.rb +13 -9
- data/lib/ox/cdata.rb +0 -2
- data/lib/ox/comment.rb +0 -2
- data/lib/ox/doctype.rb +0 -2
- data/lib/ox/document.rb +3 -5
- data/lib/ox/element.rb +41 -26
- data/lib/ox/error.rb +0 -3
- data/lib/ox/hasattrs.rb +7 -8
- data/lib/ox/instruct.rb +4 -6
- data/lib/ox/node.rb +3 -4
- data/lib/ox/raw.rb +0 -2
- data/lib/ox/sax.rb +20 -36
- data/lib/ox/version.rb +1 -2
- data/lib/ox/xmlrpc_adapter.rb +5 -6
- data/lib/ox.rb +15 -16
- metadata +27 -6
data/ext/ox/cache.c
CHANGED
@@ -34,7 +34,7 @@ typedef struct _slot {
|
|
34
34
|
volatile uint32_t use_cnt;
|
35
35
|
uint8_t klen;
|
36
36
|
char key[CACHE_MAX_KEY];
|
37
|
-
} *
|
37
|
+
} *Slot;
|
38
38
|
|
39
39
|
typedef struct _cache {
|
40
40
|
volatile Slot *slots;
|
@@ -52,7 +52,7 @@ typedef struct _cache {
|
|
52
52
|
#endif
|
53
53
|
uint8_t xrate;
|
54
54
|
bool mark;
|
55
|
-
} *
|
55
|
+
} *Cache;
|
56
56
|
|
57
57
|
static uint64_t hash_calc(const uint8_t *key, size_t len) {
|
58
58
|
const uint8_t *end = key + len;
|
data/ext/ox/cache8.c
CHANGED
@@ -3,77 +3,74 @@
|
|
3
3
|
* All rights reserved.
|
4
4
|
*/
|
5
5
|
|
6
|
-
#include
|
6
|
+
#include "cache8.h"
|
7
|
+
|
7
8
|
#include <errno.h>
|
9
|
+
#include <stdarg.h>
|
8
10
|
#include <stdio.h>
|
11
|
+
#include <stdlib.h>
|
9
12
|
#include <string.h>
|
10
|
-
#include <stdarg.h>
|
11
13
|
|
12
14
|
#include "ruby.h"
|
13
|
-
#include "cache8.h"
|
14
15
|
|
15
|
-
#define BITS
|
16
|
-
#define MASK
|
17
|
-
#define SLOT_CNT
|
18
|
-
#define DEPTH
|
16
|
+
#define BITS 4
|
17
|
+
#define MASK 0x000000000000000FULL
|
18
|
+
#define SLOT_CNT 16
|
19
|
+
#define DEPTH 16
|
19
20
|
|
20
21
|
typedef union {
|
21
|
-
struct _cache8
|
22
|
-
slot_t
|
22
|
+
struct _cache8 *child;
|
23
|
+
slot_t value;
|
23
24
|
} Bucket;
|
24
25
|
|
25
26
|
struct _cache8 {
|
26
|
-
Bucket
|
27
|
+
Bucket buckets[SLOT_CNT];
|
27
28
|
};
|
28
29
|
|
29
|
-
static void
|
30
|
-
//static void slot_print(Cache8 cache, sid_t key, unsigned int depth);
|
30
|
+
static void cache8_delete(Cache8 cache, int depth);
|
31
|
+
// static void slot_print(Cache8 cache, sid_t key, unsigned int depth);
|
31
32
|
|
32
|
-
void
|
33
|
-
|
34
|
-
|
35
|
-
int i;
|
33
|
+
void ox_cache8_new(Cache8 *cache) {
|
34
|
+
Bucket *b;
|
35
|
+
int i;
|
36
36
|
|
37
37
|
*cache = ALLOC(struct _cache8);
|
38
38
|
for (i = SLOT_CNT, b = (*cache)->buckets; 0 < i; i--, b++) {
|
39
|
-
|
39
|
+
b->value = 0;
|
40
40
|
}
|
41
41
|
}
|
42
42
|
|
43
|
-
void
|
44
|
-
ox_cache8_delete(Cache8 cache) {
|
43
|
+
void ox_cache8_delete(Cache8 cache) {
|
45
44
|
cache8_delete(cache, 0);
|
46
45
|
}
|
47
46
|
|
48
|
-
static void
|
49
|
-
|
50
|
-
|
51
|
-
unsigned int i;
|
47
|
+
static void cache8_delete(Cache8 cache, int depth) {
|
48
|
+
Bucket *b;
|
49
|
+
unsigned int i;
|
52
50
|
|
53
51
|
for (i = 0, b = cache->buckets; i < SLOT_CNT; i++, b++) {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
if (0 != b->child) {
|
53
|
+
if (DEPTH - 1 != depth) {
|
54
|
+
cache8_delete(b->child, depth + 1);
|
55
|
+
}
|
56
|
+
}
|
59
57
|
}
|
60
58
|
xfree(cache);
|
61
59
|
}
|
62
60
|
|
63
|
-
slot_t
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
sid_t
|
68
|
-
sid_t k;
|
61
|
+
slot_t ox_cache8_get(Cache8 cache, sid_t key, slot_t **slot) {
|
62
|
+
Bucket *b;
|
63
|
+
int i;
|
64
|
+
sid_t k8 = (sid_t)key;
|
65
|
+
sid_t k;
|
69
66
|
|
70
67
|
for (i = 64 - BITS; 0 < i; i -= BITS) {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
68
|
+
k = (k8 >> i) & MASK;
|
69
|
+
b = cache->buckets + k;
|
70
|
+
if (0 == b->child) {
|
71
|
+
ox_cache8_new(&b->child);
|
72
|
+
}
|
73
|
+
cache = b->child;
|
77
74
|
}
|
78
75
|
*slot = &(cache->buckets + (k8 & MASK))->value;
|
79
76
|
|
data/ext/ox/cache8.h
CHANGED
@@ -9,15 +9,15 @@
|
|
9
9
|
#include "ruby.h"
|
10
10
|
#include "stdint.h"
|
11
11
|
|
12
|
-
typedef struct _cache8
|
13
|
-
typedef uint64_t
|
14
|
-
typedef uint64_t
|
12
|
+
typedef struct _cache8 *Cache8;
|
13
|
+
typedef uint64_t slot_t;
|
14
|
+
typedef uint64_t sid_t;
|
15
15
|
|
16
|
-
extern void
|
17
|
-
extern void
|
16
|
+
extern void ox_cache8_new(Cache8 *cache);
|
17
|
+
extern void ox_cache8_delete(Cache8 cache);
|
18
18
|
|
19
|
-
extern slot_t
|
19
|
+
extern slot_t ox_cache8_get(Cache8 cache, sid_t key, slot_t **slot);
|
20
20
|
|
21
|
-
//extern void ox_cache8_print(Cache8 cache);
|
21
|
+
// extern void ox_cache8_print(Cache8 cache);
|
22
22
|
|
23
23
|
#endif /* OX_CACHE8_H */
|