string_view 0.1.0
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 +7 -0
- data/LICENSE-simdutf.txt +25 -0
- data/LICENSE.txt +21 -0
- data/README.md +264 -0
- data/Rakefile +20 -0
- data/ext/string_view/extconf.rb +15 -0
- data/ext/string_view/simdutf.cpp +68045 -0
- data/ext/string_view/simdutf.h +13941 -0
- data/ext/string_view/simdutf_c.h +342 -0
- data/ext/string_view/string_view.c +1217 -0
- data/lib/string_view/version.rb +8 -0
- data/lib/string_view.rb +36 -0
- metadata +60 -0
data/lib/string_view.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "string_view/version"
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
# Load the precompiled binary for this Ruby version (from cibuildgem)
|
|
7
|
+
ruby_version = RUBY_VERSION[/^\d+\.\d+/]
|
|
8
|
+
require_relative "string_view/#{ruby_version}/string_view"
|
|
9
|
+
rescue LoadError
|
|
10
|
+
# Fall back to the locally compiled extension
|
|
11
|
+
require_relative "string_view/string_view"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class StringView
|
|
15
|
+
# method_missing safety net:
|
|
16
|
+
# Any String method we haven't implemented natively surfaces as a hard error
|
|
17
|
+
# rather than silently falling through.
|
|
18
|
+
def method_missing(name, *args, &block)
|
|
19
|
+
if String.method_defined?(name)
|
|
20
|
+
raise NotImplementedError,
|
|
21
|
+
"StringView##{name} not yet implemented natively. " \
|
|
22
|
+
"Call .to_s.#{name}(...) explicitly if you need it."
|
|
23
|
+
else
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def respond_to_missing?(name, include_private = false)
|
|
29
|
+
# We don't claim to respond to unimplemented String methods
|
|
30
|
+
if String.method_defined?(name)
|
|
31
|
+
false
|
|
32
|
+
else
|
|
33
|
+
super
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: string_view
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Shopify
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-03-18 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: StringView provides a read-only, zero-copy view into a frozen Ruby String,
|
|
14
|
+
avoiding intermediate allocations for slicing, searching, and delegation of transform
|
|
15
|
+
methods. Uses simdutf for SIMD-accelerated UTF-8 character counting.
|
|
16
|
+
email:
|
|
17
|
+
- ruby@shopify.com
|
|
18
|
+
executables: []
|
|
19
|
+
extensions:
|
|
20
|
+
- ext/string_view/extconf.rb
|
|
21
|
+
extra_rdoc_files: []
|
|
22
|
+
files:
|
|
23
|
+
- LICENSE-simdutf.txt
|
|
24
|
+
- LICENSE.txt
|
|
25
|
+
- README.md
|
|
26
|
+
- Rakefile
|
|
27
|
+
- ext/string_view/extconf.rb
|
|
28
|
+
- ext/string_view/simdutf.cpp
|
|
29
|
+
- ext/string_view/simdutf.h
|
|
30
|
+
- ext/string_view/simdutf_c.h
|
|
31
|
+
- ext/string_view/string_view.c
|
|
32
|
+
- lib/string_view.rb
|
|
33
|
+
- lib/string_view/version.rb
|
|
34
|
+
homepage: https://github.com/Shopify/string_view
|
|
35
|
+
licenses:
|
|
36
|
+
- MIT
|
|
37
|
+
metadata:
|
|
38
|
+
homepage_uri: https://github.com/Shopify/string_view
|
|
39
|
+
source_code_uri: https://github.com/Shopify/string_view
|
|
40
|
+
changelog_uri: https://github.com/Shopify/string_view/releases
|
|
41
|
+
post_install_message:
|
|
42
|
+
rdoc_options: []
|
|
43
|
+
require_paths:
|
|
44
|
+
- lib
|
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: 3.3.0
|
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
requirements: []
|
|
56
|
+
rubygems_version: 3.5.22
|
|
57
|
+
signing_key:
|
|
58
|
+
specification_version: 4
|
|
59
|
+
summary: Zero-copy string slicing for Ruby via a C extension.
|
|
60
|
+
test_files: []
|