Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
How to specify `frozen_string_literal: true`
Search
Kazuhiro NISHIYAMA
September 19, 2017
Technology
1
460
How to specify `frozen_string_literal: true`
RubyKaigi 2017 の LT での発表資料です。
Kazuhiro NISHIYAMA
September 19, 2017
Tweet
Share
More Decks by Kazuhiro NISHIYAMA
See All by Kazuhiro NISHIYAMA
Ruby on Rails と私
znz
0
36
riscv64.rubyci.org internal
znz
0
36
Rubyの日本語リファレンスマニュアルの現在と未来
znz
0
73
devise-two-factorを4.xから5.xに上げた話
znz
0
360
docs.ruby-lang.org/ja/ の生成方法を変えた
znz
0
88
Ubuntuのriscv64版をqemuで動かした
znz
0
110
lilo.linux.or.jpをbusterからbullseyeに上げた
znz
0
110
小規模個人アプリをRails 7.xにバージョンアップした話
znz
0
110
Ruby リファレンスマニュアル改善計画 2022 進捗報告
znz
0
160
Other Decks in Technology
See All in Technology
ExpoのインダストリーブースでみたAWSが見せる製造業の未来
hamadakoji
0
170
AI時代の新規LLMプロダクト開発: Findy Insightsを3ヶ月で立ち上げた舞台裏と振り返り
dakuon
0
300
GitHub Copilotを使いこなす 実例に学ぶAIコーディング活用術
74th
3
3.6k
20251219 OpenIDファウンデーション・ジャパン紹介 / OpenID Foundation Japan Intro
oidfj
0
300
SREには開発組織全体で向き合う
koh_naga
0
390
Amazon Quick Suite で始める手軽な AI エージェント
shimy
1
1k
S3を正しく理解するための内部構造の読解
nrinetcom
PRO
3
210
AWSを使う上で最低限知っておきたいセキュリティ研修を社内で実施した話 ~みんなでやるセキュリティ~
maimyyym
2
1.8k
チーリンについて
hirotomotaguchi
6
2.1k
Amazon Connect アップデート! AIエージェントにMCPツールを設定してみた!
ysuzuki
0
110
年間40件以上の登壇を続けて見えた「本当の発信力」/ 20251213 Masaki Okuda
shift_evolve
PRO
1
140
ハッカソンから社内プロダクトへ AIエージェント「ko☆shi」開発で学んだ4つの重要要素
sonoda_mj
6
880
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
130
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
0
270
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
2
2.7k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
180
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
My Coaching Mixtape
mlcsv
0
7
Building AI with AI
inesmontani
PRO
1
560
Transcript
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