Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
151224f
Branch off my own version of require
xaviershay May 12, 2011
6f9a15d
Can load a file from the load path without specifying the extension.
xaviershay May 12, 2011
2cb09a6
Prevent double loading of files.
xaviershay May 12, 2011
a3e3f01
Raise LoadError if file was not found.
xaviershay May 12, 2011
86ed673
Detect relative file names beginning with ./, no extension checks
xaviershay May 12, 2011
b20b293
A test file for me to try out require logic.
xaviershay May 12, 2011
42d8f82
Require extra extensions and absolute paths.
xaviershay May 13, 2011
c4b552f
Load ../ relative paths. Passes all rubyspec require tests now.
xaviershay May 14, 2011
d91179d
Load non-ruby files.
xaviershay May 14, 2011
ac9498d
Deal with case-insensitive requires in a dodgy manner.
xaviershay May 14, 2011
2bedcb9
Try caching downcase method. Largely ineffective.
xaviershay May 15, 2011
301eaae
Access ivar directly rather than using rb_funcall, good speed gain.
xaviershay May 15, 2011
3e03f7f
Use a case-insensitive hash table lookup rather than a loop to check …
xaviershay May 15, 2011
5ae2a0e
Remove debugging prints
xaviershay May 15, 2011
e23f97e
Proxy so the loaded hash can be rebuilt whenever it is modified. Thi…
xaviershay May 15, 2011
460fb8f
Use require_2 for all require_2 tests
xaviershay May 15, 2011
88f9bab
Raise security exception if loading from tainted load path.
xaviershay May 15, 2011
eb8ee9a
Can require DLEXT and DLEXT2.
xaviershay May 15, 2011
41ed774
Ignore generated win32ole file
xaviershay May 15, 2011
cb12cc2
Provides backwards compatibility for enumerable without hacking into …
xaviershay May 15, 2011
d5567a3
Move lazy initialization of new_loading_table into accessor so it is …
xaviershay May 15, 2011
da2f6b2
Move safety checks up out of algorithmic method.
xaviershay May 15, 2011
aba32cf
Shuffle around code so the three find_file_ methods look the same
xaviershay May 15, 2011
cffaa8e
DRY up finding files with extensions.
xaviershay May 15, 2011
d31fbb1
Don't require .rb.rb files when only .rb is asked for.
xaviershay May 15, 2011
60aaf0b
Try loading alternate DLEXT when asking for SO file.
xaviershay May 15, 2011
de8b4e7
Use new CHAR_ARRAY_LEN macro for available_extensions.
xaviershay May 15, 2011
ee48900
Don't try to require directories.
xaviershay May 15, 2011
cacd227
Remove some compiler warnings.
xaviershay May 15, 2011
f19623d
Allow circular requires.
xaviershay May 15, 2011
d8a2bf6
require_relative_2 for new require code
xaviershay May 15, 2011
e43847f
Hook Array#delete for
xaviershay May 15, 2011
058323a
rb_require_safe_2 returns the path loaded rather than a boolean, prep…
xaviershay May 15, 2011
c442bce
Use new require code for autoloading. This fails one spec in
xaviershay May 15, 2011
e52a34b
Optimize rb_is_relative_path
xaviershay May 15, 2011
752c955
Use CHAR_ARRAY_LEN macro in define_loaded_features_proxy
xaviershay May 16, 2011
3df711d
Extract rb_locate_file method.
xaviershay May 16, 2011
e3d72d6
Simplify and clean up load.c
xaviershay May 16, 2011
8686576
Define methods in header so I can move them around, mark pretty much …
xaviershay May 16, 2011
8652090
Rename find_file to locate_file to be consistent.
xaviershay May 16, 2011
0abe5a7
More consistent naming.
xaviershay May 16, 2011
1c088c6
Rename new_loading_table to loaded_features_hash
xaviershay May 16, 2011
06aa81a
Some more forward declarations.
xaviershay May 16, 2011
30b72cd
Fix rb_feature_provided to actually do what it is supposed to.
xaviershay May 20, 2011
d7d6c41
Remove old loading code, switch require over to use new code path.
xaviershay May 20, 2011
4b6040b
Whitespace: convert spaces to tabs.
xaviershay May 20, 2011
49beb20
Don't needlessly create a new string in rb_feature_provided.
xaviershay May 20, 2011
1b94e34
Leave myself some notes as to what to do next.
xaviershay May 20, 2011
aca6251
Create fewer string objects, use rb_str_* methods directly.
xaviershay May 22, 2011
315a20a
Cache filename expansions. This gives about a 6 second speed up to a …
xaviershay May 23, 2011
3304125
Flip the order of rb_feature_provided_* to avoid a compiler warning.
xaviershay May 23, 2011
729caae
Add a missing Qnil check that was causing autoload tests to segfault.
xaviershay May 23, 2011
9158b2a
Fix failing test_dot_dot.rb test in make test-all.
xaviershay May 23, 2011
74bb0b6
Add a note to myself about what to do next.
xaviershay May 23, 2011
b68d668
Remove note to self: tried it, made no difference.
xaviershay May 23, 2011
a60f97c
Use a few more file and string functions directly.
xaviershay May 23, 2011
07fada2
Completely replace the old require functions.
xaviershay May 23, 2011
9005515
Document and shuffle around some functions for better readability.
xaviershay May 23, 2011
5fe4248
Merge branch 'trunk' into require-performance-fix
xaviershay May 23, 2011
93c4717
Remove old prototyping code.
xaviershay May 23, 2011
fcfa394
Needed to compile on debian, according to Eric Wong.
xaviershay May 24, 2011
0757268
Use the load path correctly in miniruby build files so that mkmf requ…
xaviershay May 27, 2011
1f01734
Hook $LOADED_FEATURES#<< as well
xaviershay May 27, 2011
21f7d11
Merge branch 'trunk' into require-performance-fix
xaviershay May 27, 2011
58771f3
Search for .rb files first through entire load path before searching …
xaviershay May 27, 2011
23724fc
Only calculate file extension once.
xaviershay May 27, 2011
6d6f204
Cleanup
xaviershay May 27, 2011
6bd8bcb
Surround macros in parenthesis to avoid unintended associativity surp…
xaviershay May 28, 2011
11203f2
Add support for requiring test.1.rb (thanks Evan Owen)
xaviershay May 29, 2011
992c68c
Merge branch 'trunk' into require-performance-fix
xaviershay May 30, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Shuffle around code so the three find_file_ methods look the same
  • Loading branch information
xaviershay committed May 15, 2011
commit aba32cfe79e962bbcd154def9d15383629c98f3c
33 changes: 11 additions & 22 deletions load.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ rb_find_file_absolute(VALUE fname)
VALUE expanded_file_name;

base_file_name = fname;

for (j = 0; j < number_of_available_extensions; ++j) {
expanded_file_name = rb_funcall(base_file_name, rb_intern("+"), 1, rb_str_new2(available_extensions[j]));

Expand All @@ -816,14 +817,8 @@ rb_find_file_absolute(VALUE fname)
}
}
return Qnil;

// TODO: Deal with extensions
if (rb_feature_exists(expanded_file_name)) {
return expanded_file_name;
} else {
return Qnil;
}
}

VALUE
rb_find_file_relative(VALUE fname)
{
Expand All @@ -832,6 +827,7 @@ rb_find_file_relative(VALUE fname)
VALUE expanded_file_name;

base_file_name = rb_file_expand_path(fname, Qnil);

for (j = 0; j < number_of_available_extensions; ++j) {
expanded_file_name = rb_funcall(base_file_name, rb_intern("+"), 1, rb_str_new2(available_extensions[j]));

Expand All @@ -840,34 +836,27 @@ rb_find_file_relative(VALUE fname)
}
}
return Qnil;

// TODO: Deal with extensions
if (rb_feature_exists(expanded_file_name)) {
return expanded_file_name;
} else {
return Qnil;
}
}
// TODO: Consistent naming across expanded_file_name and expanded_path

VALUE
rb_find_file_in_load_path(VALUE fname)
{
long i, j;
VALUE load_path = rb_get_expanded_load_path();
VALUE expanded_path = Qnil;
VALUE expanded_file_name = Qnil;
VALUE base_file_name = Qnil;

for (i = 0; i < RARRAY_LEN(load_path); ++i) {
VALUE directory = RARRAY_PTR(load_path)[i];

// TODO: Don't check extra extensions if an extension is provided
base_file_name = rb_funcall(directory, rb_intern("+"), 1, rb_str_new2("/"));
base_file_name = rb_funcall(base_file_name, rb_intern("+"), 1, fname);

for (j = 0; j < number_of_available_extensions; ++j) {
expanded_path = rb_funcall(directory, rb_intern("+"), 1, rb_str_new2("/"));
expanded_path = rb_funcall(expanded_path, rb_intern("+"), 1, fname);
expanded_path = rb_funcall(expanded_path, rb_intern("+"), 1, rb_str_new2(available_extensions[j]));
expanded_file_name = rb_funcall(base_file_name, rb_intern("+"), 1, rb_str_new2(available_extensions[j]));

if (rb_feature_exists(expanded_path)) {
return expanded_path;
if (rb_feature_exists(expanded_file_name)) {
return expanded_file_name;
}
}
}
Expand Down