fast_method_source 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/ext/fast_method_source/fast_method_source.c +21 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a8566fbdf9afc48e1122cd29d4ee799a455fd10
|
4
|
+
data.tar.gz: 3894ea5f9ab5e1b784b8c64078accf4b309323fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ebf626281536e5d5ec319bc5bf3eb820cfa2e1191f07c5d7d7b94afcc1de95a0be63acafd01bbc93800e53753c399527243a27cd9e372da28b05a5133dc1557
|
7
|
+
data.tar.gz: f6a255e157ba75498e4b1005d462c9851da0c762cb9b81b096f754051b5e9ba056687c7ccc590e9229fda724928f37b1ba49ab35e42138e2737ac37b78a165a3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -54,7 +54,7 @@ Method Source is about 5-10x faster than its competitor.
|
|
54
54
|
I'd be remiss if I didn't mention that there's also room for further speed
|
55
55
|
improvements. The benchmarks below represent comparison of both libraries.
|
56
56
|
|
57
|
-
#### #
|
57
|
+
#### #comment_and_source
|
58
58
|
##### ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
|
59
59
|
|
60
60
|
This is a utility method and method_source doesn't feature it.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -355,18 +355,28 @@ free_memory_for_file(char **file[], const unsigned relevant_lines_n)
|
|
355
355
|
free(*file);
|
356
356
|
}
|
357
357
|
|
358
|
+
static void
|
359
|
+
check_if_nil(VALUE val, VALUE name)
|
360
|
+
{
|
361
|
+
if (NIL_P(val)) {
|
362
|
+
rb_raise(rb_eSourceNotFoundError, "could not locate source for %s",
|
363
|
+
RSTRING_PTR(rb_sym2str(name)));
|
364
|
+
}
|
365
|
+
}
|
366
|
+
|
358
367
|
static VALUE
|
359
368
|
mMethodExtensions_source(VALUE self)
|
360
369
|
{
|
361
370
|
VALUE source_location = rb_funcall(self, rb_intern("source_location"), 0);
|
362
371
|
VALUE name = rb_funcall(self, rb_intern("name"), 0);
|
372
|
+
|
373
|
+
check_if_nil(source_location, name);
|
374
|
+
|
363
375
|
VALUE rb_filename = RARRAY_AREF(source_location, 0);
|
364
376
|
VALUE rb_method_location = RARRAY_AREF(source_location, 1);
|
365
377
|
|
366
|
-
|
367
|
-
|
368
|
-
RSTRING_PTR(rb_sym2str(name)));
|
369
|
-
}
|
378
|
+
check_if_nil(rb_filename, name);
|
379
|
+
check_if_nil(rb_method_location, name);
|
370
380
|
|
371
381
|
const char *filename = RSTRING_PTR(rb_filename);
|
372
382
|
const unsigned method_location = FIX2INT(rb_method_location);
|
@@ -376,10 +386,7 @@ mMethodExtensions_source(VALUE self)
|
|
376
386
|
filename, &filebuf);
|
377
387
|
VALUE source = find_source(&filebuf, relevant_lines_n);
|
378
388
|
|
379
|
-
|
380
|
-
rb_raise(rb_eSourceNotFoundError, "could not locate source for %s!",
|
381
|
-
RSTRING_PTR(rb_sym2str(name)));
|
382
|
-
}
|
389
|
+
check_if_nil(source, name);
|
383
390
|
free_memory_for_file(&filebuf, relevant_lines_n);
|
384
391
|
|
385
392
|
return source;
|
@@ -390,13 +397,14 @@ mMethodExtensions_comment(VALUE self)
|
|
390
397
|
{
|
391
398
|
VALUE source_location = rb_funcall(self, rb_intern("source_location"), 0);
|
392
399
|
VALUE name = rb_funcall(self, rb_intern("name"), 0);
|
400
|
+
|
401
|
+
check_if_nil(source_location, name);
|
402
|
+
|
393
403
|
VALUE rb_filename = RARRAY_AREF(source_location, 0);
|
394
404
|
VALUE rb_method_location = RARRAY_AREF(source_location, 1);
|
395
405
|
|
396
|
-
|
397
|
-
|
398
|
-
RSTRING_PTR(rb_sym2str(name)));
|
399
|
-
}
|
406
|
+
check_if_nil(rb_filename, name);
|
407
|
+
check_if_nil(rb_method_location, name);
|
400
408
|
|
401
409
|
const char *filename = RSTRING_PTR(rb_filename);
|
402
410
|
const unsigned method_location = FIX2INT(rb_method_location);
|
@@ -406,10 +414,7 @@ mMethodExtensions_comment(VALUE self)
|
|
406
414
|
filename, &filebuf);
|
407
415
|
VALUE comment = find_comment(&filebuf, method_location, relevant_lines_n);
|
408
416
|
|
409
|
-
|
410
|
-
rb_raise(rb_eSourceNotFoundError, "could not locate comment for %s!",
|
411
|
-
RSTRING_PTR(rb_sym2str(name)));
|
412
|
-
}
|
417
|
+
check_if_nil(comment, name);
|
413
418
|
free_memory_for_file(&filebuf, relevant_lines_n);
|
414
419
|
|
415
420
|
return comment;
|