Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Cocos2dx(Ver2)が闇な話
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ぽんこつ
June 28, 2014
Technology
0
210
Cocos2dx(Ver2)が闇な話
Cocos2dx(Ver2)が如何に闇かCCArrayというCocos2dx(Ver2)の闇の凝縮体の解説を元に暴く
ぽんこつ
June 28, 2014
Tweet
Share
More Decks by ぽんこつ
See All by ぽんこつ
艦これHacking
ponkotuy
0
3.8k
Other Decks in Technology
See All in Technology
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
15 years with Rails and DDD (AI Edition)
andrzejkrzywda
0
200
SREじゃなかった僕らがenablingを通じて「SRE実践者」になるまでのリアル / SRE Kaigi 2026
aeonpeople
6
2.5k
Bedrock PolicyでAmazon Bedrock Guardrails利用を強制してみた
yuu551
0
260
What happened to RubyGems and what can we learn?
mikemcquaid
0
310
Kiro IDEのドキュメントを全部読んだので地味だけどちょっと嬉しい機能を紹介する
khmoryz
0
210
プロダクト成長を支える開発基盤とスケールに伴う課題
yuu26
4
1.4k
量子クラウドサービスの裏側 〜Deep Dive into OQTOPUS〜
oqtopus
0
140
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
160
30万人の同時アクセスに耐えたい!新サービスの盤石なリリースを支える負荷試験 / SRE Kaigi 2026
genda
4
1.4k
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
5.6k
データの整合性を保ちたいだけなんだ
shoheimitani
8
3.2k
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
450
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
What does AI have to do with Human Rights?
axbom
PRO
0
2k
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
Navigating Weather and Climate Data
rabernat
0
110
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
290
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
The Invisible Side of Design
smashingmag
302
51k
Transcript
͡Ίʹ Cocos2dx ͱ CCArray ݁ Cocos2dx(Ver2) ͕ҋͳ ΆΜͭ͜ 2014
06 ݄ 28 ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ ࣗݾհ ΆΜͭ͜Ͱ͢ (@ponkotuy) ܳऀ౦ژΤϯλʔςΠϝϯτͰήʔϜ࡞ͬͯ·͢ C++͡Όͳͯ͘
Scala ͷਓͰ͢ ΏͱΓϓϩάϥϚʹ C++ͱϝϞϦཧແཧա͗ͨ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ ͢༰ Cocos2dx(Ver2) ͕ਏ͍Λ͠·͢ C++03 Ҏલͷ
No Constexpr, No Template ·ͱͳ C++ͷΛظ͍ͯ͠Δํٳܜ࣌ؒͰ͢ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ ιγϟή։ൃͷݱ Wanted ϦονͳεϚʔτϑΥϯΞϓϦ (ωΠςΟϒ) Required
ϚϧνϓϥοτϑΥʔϜ (ಛʹ iOS + Android) Must σβΠφʔͱͷ࿈ܞ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ Cocos2dx ͳΒͰ͖ΔΑʂ ϚϧνϓϥοτϑΥʔϜͳωΠςΟϒΞϓϦ͕࡞Մೳ CocosBuilder Λͬͯը໘ɾΞχϝʔγϣϯ࡞
C++Ͱ Obj-C ΑΓϦονͳϓϩάϥϛϯάڥ ຊʹ Obj-C ΑΓϦον͔ʁ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ Cocos2dx ͷݱ࣮ Cocos2dx Objective-C
൛ Cocos2d ͷ C++Ҡ২ ݁ͱͯ͠։ൃऀ͕ C++͔ͬͯͳ͍ ࣮ମྼԽ Objective-C ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ Cocos2dx(Ver2) ͷCCArray Cocos2dx ͷ CCArray
class Objective-C Ͱ NSArray ΑΓߴͱͯ͠༻Λਪ زΒ͔ͷඪ४ͷϝιου͕ CCArray Λฦͯ͘͠Δ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ CCArray ͷAPI Create static CCArray*
create(); Insert void addObject(CCObject* object); CCObject ͱ͔͍͏Կ͔͓ͧ·͍͠ͷ͕ ཁૉ CCObject ͷܧঝ͕Ϛετ CCObject Java ͷશͯͷجఈΫϥε Object Έ͍ͨͳ Cocos2dx ͷΫϥεຆͲશͯ CCObject Λܧঝ͍ͯ͠Δ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ CCArray ͷAPI ͦͷ2 ϧʔϓͷճ͠ํ CCARRAY_FOREACH(ccArray,
obj) { CCNode* node = static_cast<CCNode*>(obj); ... } CCARRAY_FOREACH ͱ͍͏ಾϚΫϩ Ұ୴ CCObject ʹม͞ΕΔͷͰϒνյ͞ΕΔܕใ ͪͳΈʹ iterator ࣮͞Εͯͳ͍ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ CCArray ͱstd::vector ͷൺֱ std::vector ͱҎԼͷૢ࡞Ͱൺֱ͢Δ
oat ܕͰ 0 ͔Β n ·ͰίϯςφʹಥͬࠐΉ ˢΛͯ͠߹ܭΛग़͢ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ std::vectorʢC++03ʣͷ߹ float stdVectorSum(float count) {
std::vector<float> vec; for(float f = 0.0f; f < count; ++f) vec.push_back(f); return std::accumulate( vec.begin(), vec.end(), 0.0f); } ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ CCArray ͷ߹ float ccArraySum(float count)
{ CCArray* array = CCArray::create(); for(float f = 0.0f; f < count; ++f) array->addObject(new CCFloat(f)); float sum = 0.0f; CCObject* elem = NULL; CCARRAY_FOREACH(array, elem) { CCFloat* f = static_cast<CCFloat*>(elem); sum += f->getValue(); } return sum; } ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ CCArray ͷͭΒ͍ͱ͜Ζ CCFloat ͱ͍͏ CCObject
Λܧঝͨ͠ class ͕ඞཁ STL ͷΞϧΰϦζϜ͕͑ͳ͍ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ ൺֱ CPU Core i5-4570S 2.90GHz
OS Ubuntu 14.04 CXX g++4.8.2 CXXFLAGS -O3 Ͱ 10000000 ສཁૉɺઌఔͷίʔυΛճͨ݁͠Ռ͕ CCArray 0.569s std::vector<oat> 0.057s std::vector<CCFloat> 0.397s ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ ݁ CCArray 0.569s std::vector<oat> 0.057s
std::vector<CCFloat> 0.397s CCArray ͷ͍ͷ CCFloat ͷ boxingɺunboxing ͕ݪҼ ͨͩ͠ std::vector<CCFloat>Ͱ CCArray ͷํ͕͍ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ ͪͳΈʹ array->addObject(new CCFloat(f)); ͜ΕϦʔΫͯ͠·ͤΜɻ CCObject
ࢀরΧϯτํࣜͷࣗಈղ์Λ࣋ͭ addObject Ͱ retain Λൃߦ (ࢀরΧϯτ͕+1 removeObject Ͱ release Λൃߦ (ࢀরΧϯτ͕-1 ͞ΕΔҝͰ͢ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ ݁ ॳظͷεϚϗήʔϜ։ൃͰڧྗͩͬͨ Cocos2dx Cocos2dx(Ver2) ͷશମతʹ
CCArray Ϩϕϧͷ೦ઃܭ boxingɺunboxing ͜Θ͍ɺ͍ ·ͣͪΌΜͱ STL ͓͏ Unity(C#) ͔ Cocos2dx(Ver3) ͍͍ͨ ΆΜͭ͜ Cocos2dx(Ver2) ͕ҋͳ
͡Ίʹ Cocos2dx ͱ CCArray ݁ ͦͷଞ ܭଌʹͬͨίʔυ https://github.com/ponkotuy/CocosSample ΆΜͭ͜ Cocos2dx(Ver2)
͕ҋͳ