# static dispatch

6개의 포스트

Fluent Rust - Constructor Injection

Constructor Injection? In Object-Oriented Programming world, we often use Constructor Injection pattern, which is where you define a list of required dependencies by specifying them as paramters when constructing a class. In this post, I'll be showing you a tiny little and simple example of how you may implement constrctor injection in Rust. > Well, Rust doesn't have class, as it disassemble class into struct for data and impl for attached behaviours. So the use of class i

2023년 9월 8일
·
0개의 댓글
·
post-thumbnail

[번역] Method Dispatch

아래의 내용을 번역한 내용입니다. https://medium.com/@bakshioye/static-vs-dynamic-dispatch-in-swift-a-decisive-choice-cece1e872d Method Dispatch Static dispatch는 value 타입과 reference타입을 모두 지원한다. 그러나 Dynamic Dispatch는 refence type만을 지원한다. reference type은 상속을 위해 dynamic dispatch가 필요하고 value type은 상속을 지원하지 않는다. Dispatch techniques에는 static, dynamic뿐만 아니라 4가지를 지원한다. Inlin(Fastest) Static Dispatch Virtual Dispatch Dynamic Distpach(Slowest) Static vc Dynamic 기본적으로, Objective-c는 Dynamic Dispatc

2022년 10월 9일
·
0개의 댓글
·
post-thumbnail

Swift | final 키워드로 성능 올리기

저는 어디서 final 을 class 앞에 작성하면 성능이 올라간다고 했던 것을 보고 항상 final class 하곤 했는데요. final 이 정확히 어떤 동작을 하는 건지 궁금해서 블로그 작성해보기 (ᴗ͈ˬᴗ͈)ꕤ.゚ final 관련한 애플 공식 문서를 찾아보니 Increasing Performance by Reducing Dynamic Dispatch 즉, Dynamic Dispatch 를 줄여 성능 향상을 한다는 제목의 글에서 final 이 보였어요. 그럼 final 을 알아보기 전 Dynamic Dispatch 관련해서 공부를 먼저 해봅시다 ( ˘-˘)ว Dynamic Dispatch Dynamic Dispatch 는 Method Dispatch의 한 종류에요. 그럼 또 Method Dispatch 에 대해서 알아보고 나서 **Dynamic Disp

2022년 8월 31일
·
0개의 댓글
·
post-thumbnail

[Swift] Increasing Performance by Reducing Dynamic Dispatch

Class를 쓰게 되면 final 키워드를 붙여 상속이 안되게 해주자라는 의미로 작성했었는데 왜 그렇게 해야 좋은걸까 고민을 하기 시작했다. Increasing Performance by Reducing Dynamic Dispatch를 읽고 정리했습니다. Increasing Performance by Reducing Dynamic Dispatch 다른 언어와 마찬가지로 Swift도 SuperClass에 선언된 메소드와 프로퍼티 선언을 override 할 수 있다. 프로그램이 런타임에 어떤 메소드와 프로퍼티를 참조할지 결정하고, indirect call(간접 호출), indirect access(간접 접근)을 수행해야 한다. 이것을 Dynamic Dispatch 이라 불리며, indirect call(간접 호출) / indirect access

2021년 10월 8일
·
0개의 댓글
·
post-thumbnail

[Swift] Dynamic, Static Dispatch

Swift는 객체지향언어이기에 상속이라는 개념이 있다. 자식클래스는 부모클래스의 메소드와 프로퍼티들을 오버라이드(재정의)할 수 있다. 이렇게 오버라이드를 하게 될 경우, 프로그램은 실제 함수 호출을 어떻게 할지 알아보자 Dispatch Dispatch 는 어떤 메소드, 프로퍼티를 사용할 것인지를 결정하는 것이다. Dispatch 의 종류에는 Static과 Dynamic이 있다. Static vs Dynamic Dispatch?? Static Dispatch 는 컴파일 타임에 실제 호출할 함수를 결정할 수 있기 때문에 함수 호출 과정이 간단하고, 컴파일러가 이것을 최적할 수 있는 여지가 많다. 하지만, 참조 타입에 따라 호출될 함수가 결정이 되기 때문에 서브클래스의 장점을 누리기 어렵다 Dynamic Dispatch 는 런타임에 호출될 함수를 결정한다. 이를 위해서 Swift에서는 클래스마다 (Virtual Dispatch

2021년 3월 16일
·
0개의 댓글
·
post-thumbnail

Understanding Swift Performance (Struct VS Class) - 3

지난 포스팅은 WWDC 2016 Understanding Swift Performance 영상에서 reference counting에 대해서 알아보았다. 👉🏻 지난포스팅이 궁금하신 분들은 여기를 눌러주세요!! 이번 포스팅에서는 이제 performance의 마지막 측면인 method dispatch에 대해서 알아 볼 것이다. method dispatch Swift에서 runtime에 메소드를 호출하게 되면, Swift는 정확한 구현을 실행해야한다. 이러한 method dispatch에는 static dispatch 와 dynamic dispatch 가 있다. static dispatch ![](https://images.velog.io/images/minni/post/cff6ef91-f0a3-48e0-bb5c-690c8

2020년 12월 27일
·
0개의 댓글
·