ox 2.14.13 → 2.14.15

Sign up to get free protection for your applications and to get access to all the features.
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
- } * Slot;
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
- } * Cache;
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 <stdlib.h>
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 4
16
- #define MASK 0x000000000000000FULL
17
- #define SLOT_CNT 16
18
- #define DEPTH 16
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 *child;
22
- slot_t value;
22
+ struct _cache8 *child;
23
+ slot_t value;
23
24
  } Bucket;
24
25
 
25
26
  struct _cache8 {
26
- Bucket buckets[SLOT_CNT];
27
+ Bucket buckets[SLOT_CNT];
27
28
  };
28
29
 
29
- static void cache8_delete(Cache8 cache, int depth);
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
- ox_cache8_new(Cache8 *cache) {
34
- Bucket *b;
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
- b->value = 0;
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
- cache8_delete(Cache8 cache, int depth) {
50
- Bucket *b;
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
- if (0 != b->child) {
55
- if (DEPTH - 1 != depth) {
56
- cache8_delete(b->child, depth + 1);
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
- ox_cache8_get(Cache8 cache, sid_t key, slot_t **slot) {
65
- Bucket *b;
66
- int i;
67
- sid_t k8 = (sid_t)key;
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
- k = (k8 >> i) & MASK;
72
- b = cache->buckets + k;
73
- if (0 == b->child) {
74
- ox_cache8_new(&b->child);
75
- }
76
- cache = b->child;
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 *Cache8;
13
- typedef uint64_t slot_t;
14
- typedef uint64_t sid_t;
12
+ typedef struct _cache8 *Cache8;
13
+ typedef uint64_t slot_t;
14
+ typedef uint64_t sid_t;
15
15
 
16
- extern void ox_cache8_new(Cache8 *cache);
17
- extern void ox_cache8_delete(Cache8 cache);
16
+ extern void ox_cache8_new(Cache8 *cache);
17
+ extern void ox_cache8_delete(Cache8 cache);
18
18
 
19
- extern slot_t ox_cache8_get(Cache8 cache, sid_t key, slot_t **slot);
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 */