Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
d78acc7a
Commit
d78acc7a
authored
Sep 26, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add index to larger segment lists for performance
parent
8ffd4e47
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
329 additions
and
127 deletions
+329
-127
mrbgems/mruby-array-ext/mrblib/array.rb
mrbgems/mruby-array-ext/mrblib/array.rb
+4
-10
mrblib/hash.rb
mrblib/hash.rb
+1
-1
src/hash.c
src/hash.c
+324
-116
No files found.
mrbgems/mruby-array-ext/mrblib/array.rb
View file @
d78acc7a
# coding: cp932
class
Array
##
# call-seq:
...
...
@@ -41,26 +42,19 @@ class Array
# c.uniq! { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]]
#
def
uniq!
(
&
block
)
hash
=
{}
if
block
hash
=
{}
self
.
each
do
|
val
|
key
=
block
.
call
(
val
)
hash
[
key
]
=
val
unless
hash
.
key?
(
key
)
end
result
=
hash
.
values
els
if
self
.
size
>
20
els
e
hash
=
{}
self
.
each
do
|
val
|
hash
[
val
]
=
val
end
result
=
hash
.
values
else
ary
=
self
.
dup
result
=
[]
while
ary
.
size
>
0
result
<<
ary
.
shift
ary
.
delete
(
result
.
last
)
end
result
=
hash
.
keys
end
if
result
.
size
==
self
.
size
nil
...
...
mrblib/hash.rb
View file @
d78acc7a
...
...
@@ -334,7 +334,7 @@ class Hash
# h["AA"] #=> "b"
#
def
rehash
self
.
size
# do nothing (for now)
self
end
end
...
...
src/hash.c
View file @
d78acc7a
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment