This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 66617692509 -> strhash( Test ) | |
| 1 66617692515 <- 1796846687 strhash | |
| 1 66617692520 -> strhash( Test ) | |
| 1 66617692526 <- 1796846687 strhash | |
| 1 66617692530 -> numhash( 10653 ) | |
| 1 66617692535 <- 10653 numhash | |
| 1 66617692613 -> numhash( 10653 ) | |
| 1 66617692619 <- 10653 numhash | |
| 1 66617692623 -> numhash( 10653 ) | |
| 1 66617692627 <- 10653 numhash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0 66912008017 -> st_init_table_with_size( 760124, 0 ) | |
| 0 66912008022 -> new_size( 1174848 ) | |
| 0 66912008026 <- 11 new_size | |
| 0 66912008031 <- st_init_table_with_size | |
| 0 66912008035 <- st_init_table | |
| 0 66912008038 <- st_init_numtable | |
| 0 66912008042 -> st_init_numtable(void) | |
| 0 66912008047 -> st_init_table( 760124 ) | |
| 0 66912008051 -> st_init_table_with_size( 760124, 0 ) | |
| 0 66912008056 -> new_size( 11 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0 67232268168 -> numhash( 10204 ) | |
| 0 67232268173 <- 10204 numhash | |
| 0 67232268179 -> st_lookup( <st_table num_bins: 283, num_entries: 957>, 673940, 59452 ) | |
| 0 67232268184 -> strhash( allocate ) | |
| 0 67232268191 <- 948867196 strhash | |
| 0 67232268195 <- 1 st_lookup | |
| 0 67232268199 -> numhash( 10204 ) | |
| 0 67232268204 <- 10204 numhash | |
| 0 67232268209 -> st_lookup( <st_table num_bins: 283, num_entries: 957>, 677101, 28 ) | |
| 0 67232268215 -> strhash( garbage_collect ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0 68425078408 -> numhash( 10209 ) | |
| 0 68425078413 <- 10209 numhash | |
| 0 68425078417 <- 0 st_insert | |
| 0 68425078422 -> st_lookup( <st_table num_bins: 283, num_entries: 958>, 677117, 4 ) | |
| 0 68425078428 -> strhash( ObjectSpace ) | |
| 0 68425078435 <- 3997301169 strhash | |
| 0 68425078439 <- 0 st_lookup | |
| 0 68425078444 -> st_add_direct( <st_table num_bins: 283, num_entries: 958>, 1181008, 10221 ) | |
| 0 68425078449 -> strhash( ObjectSpace ) | |
| 0 68425078455 <- 3997301169 strhash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ReverseMerge | |
| # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. | |
| def reverse_merge(other_hash) | |
| other_hash.merge(self) | |
| end | |
| # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. | |
| # Modifies the receiver in place. | |
| def reverse_merge!(other_hash) | |
| replace(reverse_merge(other_hash)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'active_support' | |
| require "rbench" | |
| class Hash | |
| def fast_reverse_merge( other_hash ) | |
| self.merge( other_hash ){|k,o,n| o } | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'active_support' | |
| require "benchmark" | |
| class Hash | |
| def fast_reverse_merge!(other_hash) | |
| if respond_to?(:convert_key, true) | |
| replace(reverse_merge(other_hash)) | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macbook-pros-computer:~ lourens$ ruby hash_query.rb | |
| Rehearsal ---------------------------------------------------------------------- | |
| fast_reverse_merge!: 0.020000 0.000000 0.020000 ( 0.021689) | |
| fast_reverse_merge! (indifferent): 0.280000 0.000000 0.280000 ( 0.290316) | |
| reverse_merge! 0.030000 0.000000 0.030000 ( 0.041295) | |
| reverse_merge! (indifferent) 0.330000 0.000000 0.330000 ( 0.339491) | |
| ------------------------------------------------------------- total: 0.660000sec | |
| user system total real | |
| fast_reverse_merge!: 0.020000 0.000000 0.020000 ( 0.021406) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef struct OpenFile { | |
| FILE *f; /* stdio ptr for read/write */ | |
| FILE *f2; /* additional ptr for rw pipes */ | |
| int mode; /* mode flags */ | |
| int pid; /* child's pid (for pipes) */ | |
| int lineno; /* number of lines read */ | |
| char *path; /* pathname for file */ | |
| void (*finalize) _((struct OpenFile*,int)); /* finalize proc */ | |
| } OpenFile; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * The constants supported by Ruby for use with IO::fcntl are: | |
| * | |
| * - F_DUPFD - duplicate a close-on-exec file handle to a non-close-on-exec | |
| * file handle. | |
| * | |
| * - F_GETFD - read the close-on-exec flag of a file handle. | |
| * | |
| * - F_SETFD - set the close-on-exec flag of a file handle. | |
| * | |
| * - FD_CLOEXEC - the value of the close-on-exec flag. |