C-koodin refaktorointi koodin koon parantamiseksi

Read full text
Authors: Aleksi Sohlman
Cited by: 0
References: 28

Abstract

IoT devices have become increasingly common in the 2020s, and their numbers are expected to continue growing in the future as well. In order for small IoT devices to be produced in a commercially viable way, they must be manufactured using low-cost components whose capacities may be limited. One such component is flash memory. The smaller the device program code is, the cheaper the memory components can be. This can give the device manufacturer a competitive advantage. This thesis examines C language constructs from the perspective of code size. The goal is to determine if code size can be reduced by refactoring suboptimal patterns. In addition, the potential of static analysis for identifying such patterns is investigated. The ultimate purpose of the work is to find ways to reduce the code size of the Silicon Labs Bluetooth Mesh SDK. The project conducts a review of size optimization methods presented in the literature and evaluates their effectiveness in reducing program size. Furthermore, the impact of refactoring a specific pattern is examined as a case study. Instances of the suboptimal pattern are located in the Mesh SDK code and refactored into a more optimal form. A static analyzer is developed using the Clang toolchain to support this work. The tool identifies suitable locations in the source code semi-automatically. As a result of the refactoring, the code size was reduced by 318 bytes, which corresponds to approximately 0.15 percent of the total code project size. We estimate that refactoring the other reviewed patterns would yield improvements in the same order of magnitude in most codebases. Due to the relatively small savings, it appears that refactoring suboptimal patterns is worthwhile mainly as part of a broader set of optimization techniques, or in situations where reducing code size is critically important. Static analysis was found to be useful in supporting refactoring, but its use involved challenges.

Fields of Study & Subjects

Software Engineering Research Logic programming and type systems Embedded Systems Design Techniques

Publication details

Journal / source
Aaltodoc (Aalto University)
Publication date
13 February 2026
Language
EN
Document type
Thesis