slim_scrooge 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/ext/callsite_hash.c +10 -32
- data/lib/slim_scrooge/callsite.rb +1 -1
- data/test/setup.rb +1 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
data/ext/callsite_hash.c
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
|
7
7
|
static int strhash(register const char *string) {
|
8
8
|
register int c;
|
9
|
-
|
10
9
|
register int val = 0;
|
11
10
|
|
12
11
|
while ((c = *string++) != '\0') {
|
@@ -16,47 +15,26 @@ static int strhash(register const char *string) {
|
|
16
15
|
return val + (val>>5);
|
17
16
|
}
|
18
17
|
|
19
|
-
static VALUE rb_f_callsite(
|
18
|
+
static VALUE rb_f_callsite(VALUE obj) {
|
20
19
|
struct FRAME *frame = ruby_frame;
|
21
20
|
NODE *n;
|
22
|
-
int lev = -1;
|
23
21
|
int csite = 0;
|
24
22
|
|
25
|
-
if (frame->last_func == ID_ALLOCATOR)
|
26
|
-
|
27
|
-
|
28
|
-
if (
|
29
|
-
|
30
|
-
|
31
|
-
csite += strhash(ruby_sourcefile) + ruby_sourceline + frame->last_func;
|
32
|
-
}
|
33
|
-
else if (ruby_sourceline == 0) {
|
34
|
-
csite += strhash(ruby_sourcefile);
|
35
|
-
}
|
36
|
-
else {
|
37
|
-
csite += strhash(ruby_sourcefile) + ruby_sourceline;
|
38
|
-
}
|
39
|
-
if (lev < -1) return INT2FIX(csite);
|
40
|
-
}
|
41
|
-
else {
|
42
|
-
while (lev-- > 0) {
|
43
|
-
frame = frame->prev;
|
44
|
-
if (!frame) {
|
45
|
-
csite = 0;
|
46
|
-
break;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
23
|
+
if (frame->last_func == ID_ALLOCATOR) frame = frame->prev;
|
24
|
+
|
25
|
+
ruby_set_current_source();
|
26
|
+
if (ruby_sourcefile) csite += strhash(ruby_sourcefile);
|
27
|
+
csite += frame->last_func + ruby_sourceline;
|
28
|
+
|
50
29
|
for (; frame && (n = frame->node); frame = frame->prev) {
|
51
30
|
if (frame->prev && frame->prev->last_func) {
|
52
31
|
if (frame->prev->node == n) {
|
53
32
|
if (frame->prev->last_func == frame->last_func) continue;
|
54
33
|
}
|
55
|
-
csite +=
|
56
|
-
}
|
57
|
-
else {
|
58
|
-
csite += strhash(n->nd_file) + nd_line(n);
|
34
|
+
csite += frame->prev->last_func;
|
59
35
|
}
|
36
|
+
if (n->nd_file) csite += strhash(n->nd_file);
|
37
|
+
csite += nd_line(n);
|
60
38
|
}
|
61
39
|
|
62
40
|
return INT2FIX(csite);
|
@@ -54,7 +54,7 @@ module SlimScrooge
|
|
54
54
|
def essential_columns(model_class)
|
55
55
|
model_class.reflect_on_all_associations.inject([@primary_key]) do |arr, assoc|
|
56
56
|
if assoc.options[:dependent] && assoc.macro == :belongs_to
|
57
|
-
arr << assoc.
|
57
|
+
arr << assoc.primary_key_name
|
58
58
|
end
|
59
59
|
arr
|
60
60
|
end
|
data/test/setup.rb
CHANGED