summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-21 14:34:17 +0200
committerwm4 <wm4@nowhere>2018-05-24 19:56:35 +0200
commit455af6aa68a96fa38f17174c35e95e13098886e0 (patch)
tree2fd2b70987391795df03eab45653b74fe9cab2b7 /player
parent816ad035191970decb17086f5c011edffc257b6c (diff)
downloadmpv-455af6aa68a96fa38f17174c35e95e13098886e0.tar.bz2
mpv-455af6aa68a96fa38f17174c35e95e13098886e0.tar.xz
m_config: optimize initialization of each option
Options with dynamic memory allocations (such as strings) require some care. They need to be fully copied on initialization, and if a static default value was declared, we must not free that value either. Instead of going through the entire thing even for simple types like integers, really run it only for options with dynamic allocations. To distinguish types which use dynamic allocations, we can use the fact that they require a free callback (otherwise they would leak). As a result initialization of simple types becomes chaper, and the init function does nothing at all if src==dst for a simple type. (It's funny how mplayer had M_OPT_TYPE_DYNAMIC since 2002, until we replaced it by the same heuristic as used here in commit 3bb134969eb6. It's also funny how the new check was used only for some asserts, and finally removed in commit 7539928c1c. I guess at this time I felt like having uniform code was more important than pointless micro-optimizations.) The src==NULL case is removed because it can't happen.
Diffstat (limited to 'player')
0 files changed, 0 insertions, 0 deletions