Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
How to specify `frozen_string_literal: true`
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kazuhiro NISHIYAMA
September 19, 2017
Technology
520
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
How to specify `frozen_string_literal: true`
RubyKaigi 2017 の LT での発表資料です。
Kazuhiro NISHIYAMA
September 19, 2017
Transcript
13 slides
How to specify frozen_string_literal: true Kazuhiro NISHIYAMA RubyKaigi 2017 LT
2017/09/19 Powered by Rabbit 2.2.1
self.introduce One of Ruby committers Twitter, GitHub: @znz 1/12
What’s frozen_string_literal magic comment Specify string literals are frozen or
not per fle Frozen string literals are faster Generate less objects Reduce GC 2/12
Example After coding if exist example: # -*- coding: utf-8
-*- # frozen_string_literal: true p ''.frozen? #=> true 3/12
Past release Add frozen_string_literal: false for almost *.rb fles when
Ruby 2.3.0 For compatibility with --enable=frozen-string- literal command line option of ruby 4/12
Changes in this year Recent Ruby programs tend to specify
true, but ruby standard libraries are false. So I changed to frozen_string_literal: true in some fles which assigned to no maintainer in doc/ maintainers.rdoc. 5/12
Review points before change Almost RuntimeError: can't modify frozen String
points are: String#<< bang methods (e.g. String#sub!) 6/12
Overlooked modifcation IO#read(length, out_buffer) this buffer is overlooked 7/12
Find modifed string literal --debug=frozen-string-literal command line option is very
useful examples: ruby --debug=frozen-string-literal test.rb make test-all TESTS='-v base64' RUBYOPT=--debug=frozen-string-literal 8/12
Tests --debug=frozen-string-literal needs to run codes. So tests are very
important. 9/12
No change if can’t If no tests, there is no
need to forcibly change it. I think working codes are useful than broken faster codes. 10/12
mkmf.rb mkmf.rb has many tests But mkmf.rb is too complex
to me in a short time So I remain false 11/12
Conclusion No tests may overlook modifcations Use frozen_string_literal: true if
you can You can use frozen_string_literal: false in some cases for compatibility for --enable=frozen- string-literal 12/12 Powered by Rabbit 2.2.1
More Decks by Kazuhiro NISHIYAMA
See All by Kazuhiro NISHIYAMA
Reforming the Japanese Ruby reference manual
znz
0
45
Rubyの配布パッケージの変遷
znz
0
63
Headscale + Tailscale に移行中
znz
0
110
Ruby on Rails と私
znz
0
110
riscv64.rubyci.org internal
znz
0
75
Rubyの日本語リファレンスマニュアルの現在と未来
znz
0
140
devise-two-factorを4.xから5.xに上げた話
znz
0
490
docs.ruby-lang.org/ja/ の生成方法を変えた
znz
0
140
Ubuntuのriscv64版をqemuで動かした
znz
0
170
Other Decks in Technology
See All in Technology
エンタープライズIAMについて - ID・権限をどう統制するか
oidfj
1
240
PHPで家庭用ゲーム機の専用コントローラーをMIDIデバイスとして扱ってみる
wind111
0
160
個人ASを取得して、自宅Kubernetes上のVMをグローバルIPで公開した話
munenick
0
210
共通基盤の実装に Kotlin - Quarkus を選定した理由と採用したアーキテクチャ
nealle
1
140
サーバーラックは作る時代! 3Dプリンターで作る10インチラックのススメ
jacopen
2
480
自動計装なしでECSサービスをApplication Signalsに載せるまで
ota1022
2
430
ノードが消える前提で設計する!Karpenterで金融システムを止めないためのノウハウ大全
daitak
1
140
人の努力に頼らないセキュリティをエンジニアリングする在り方 / An approach to engineering security that does not rely on human effort
carta_engineering
0
220
閉域網でのAPI公開の選択肢全部比較!
takano0131
4
570
AI対話型分析を作成し、リリースするまでの話 / The Road to Release: Buiding AI Conversational Analytics
yappli_developers
0
170
未来を描き変化の中で学び直す ヴァンガードから考える、AI時代のチーム開発
lamb_moko
0
110
人間+AIを「チーム」としてプロセスを再設計する
littlehands
4
3.5k
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Bash Introduction
62gerente
615
220k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
2k
The agentic SEO stack - context over prompts
schlessera
0
1k
The Language of Interfaces
destraynor
162
27k
Building Applications with DynamoDB
mza
96
7.3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
380
Un-Boring Meetings
codingconduct
0
500
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
4
1.3k
Amusing Abliteration
ianozsvald
1
390