fast_method_source 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05784a528c431c7cf44acd224efb46961b71aab0
4
- data.tar.gz: 6c01ae108aa332254d90d3017e9b99765faacde8
3
+ metadata.gz: 8a8566fbdf9afc48e1122cd29d4ee799a455fd10
4
+ data.tar.gz: 3894ea5f9ab5e1b784b8c64078accf4b309323fb
5
5
  SHA512:
6
- metadata.gz: d61984aee9f70704d029a85d1e409be18ea9a357bac38033f8f9e27fab347adeef2138a9c60779152356cf61e70cbf0591b80c1eb5362f8c208cc506f25e1999
7
- data.tar.gz: 566c2dc70be7cd41e2c99aa063bcead973e1232b3c6729faed5337067f9f37548ad81535494f039b1c2a465c3831e82885331f79a41687cb1256e874c980d554
6
+ metadata.gz: 7ebf626281536e5d5ec319bc5bf3eb820cfa2e1191f07c5d7d7b94afcc1de95a0be63acafd01bbc93800e53753c399527243a27cd9e372da28b05a5133dc1557
7
+ data.tar.gz: f6a255e157ba75498e4b1005d462c9851da0c762cb9b81b096f754051b5e9ba056687c7ccc590e9229fda724928f37b1ba49ab35e42138e2737ac37b78a165a3
@@ -1,6 +1,10 @@
1
1
  Fast Method Source changelog
2
2
  ============================
3
3
 
4
+ ### v0.1.1 (June 9, 2015)
5
+
6
+ * Fixed segfault on any C method query
7
+
4
8
  ### v0.1.0 (June 9, 2015)
5
9
 
6
10
  * Initial release
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
- #### #commend_and_source
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.0
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
- if (NIL_P(source_location) || NIL_P(rb_method_location)) {
367
- rb_raise(rb_eSourceNotFoundError, "could not locate source for %s!",
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
- if (NIL_P(source)) {
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
- if (NIL_P(source_location) || NIL_P(rb_method_location)) {
397
- rb_raise(rb_eSourceNotFoundError, "could not locate source for %s!",
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
- if (NIL_P(comment)) {
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;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_method_source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyrylo Silin