minetest/src/client
Jozef Behran eb2bda7d0b Optimize string (mis)handling (#8128)
* Optimize statbar drawing

The texture name of the statbar is a string passed by value.
That slows down the client and creates litter in the heap
as the content of the string is allocated there. Convert the
offending parameter to a const reference to avoid the
performance hit.

* Optimize texture cache

There is an unnecessary temporary created when the texture
path is being generated. This slows down the cache each time
a new texture is encountered and it needs to be loaded into
the cache. Additionally, the heap litter created by this
unnecessary temporary is particularly troublesome here as
the following code then piles another string (the resulting
full path of the texture) on top of it, followed by the
texture itself, which both are quite long term objects as
they are subsequently inserted into the cache where they can
remain for quite a while (especially if the texture turns
out to be a common one like dirt, grass or stone).

Use std::string.append to get rid of the temporary which
solves both issues (speed and heap fragmentation).

* Optimize animations in client

Each time an animated node is updated, an unnecessary copy of
the texture name is created, littering the heap with lots of
fragments. This can be specifically troublesome when looking
at oceans or large lava lakes as both of these nodes are
usually animated (the lava animation is pretty visible).
Convert the parameter of GenericCAO::updateTextures to a
const reference to get rid of the unnecessary copy.

There is a comment stating "std::string copy is mandatory as
mod can be a class member and there is a swap on those class
members ... do NOT pass by reference", reinforcing the
belief that the unnecessary copy is in fact necessary.
However one of the first things the code of the method does
is to assign the parameter to its class member, creating
another copy. By rearranging the code a little bit this
"another copy" can then be used by the subsequent code,
getting rid of the need to pass the parameter by value and
thus saving that copying effort.

* Optimize chat console history handling

The GUIChatConsole::replaceAndAddToHistory was getting the
line to work on by value which turns out to be unnecessary.
Get rid of that unnecessary copy by converting the parameter
to a const reference.

* Optimize gui texture setting

The code used to set the texture for GUI components was
getting the name of the texture by value, creating
unnecessary performance bottleneck for mods/games with
heavily textured GUIs. Get rid of the bottleneck by passing
the texture name as a const reference.

* Optimize sound playing code in GUIEngine

The GUIEngine's code receives the specification of the sound
to be played by value, which turns out to be most likely a
mistake as the underlying sound manager interface receives
the same thing by reference. Convert the offending parameter
to a const reference to get rid of the rather bulky copying
effort and the associated performance hit.

* Silence CLANG TIDY warnings for unit tests

Change "std::string" to "const std::string &" to avoid an
unnecessary local value copy, silencing the CLANG TIDY
process.

* Optimize formspec handling

The "formspec prepend" parameter was passed to the formspec
handling code by value, creating unnecessary copy of
std::string and slowing down the game if mods add things like
textured backgrounds for the player inventory and/or other
forms. Get rid of that performance bottleneck by converting
the parameter to a const reference.

* Optimize hotbar image handling

The code that sets the background images for the hotbar is
getting the name of the image by value, creating an
unnecessary std::string copying effort. Fix that by
converting the relevant parameters to const references.

* Optimize inventory deserialization

The inventory manager deserialization code gets the
serialized version of the inventory by value, slowing the
server and the client down when there are inventory updates.
This can get particularly troublesome with pipeworks which
adds nodes that can mess around with inventories
automatically or with mods that have mobs with inventories
that actively use them.

* Optimize texture scaling cache

There is an io::path parameter passed by value in the
procedure used to add images converted from textures,
leading to slowdown when the image is not yet created and
the conversion is thus needed. The performance hit is
quite significant as io::path is similar to std::string
so convert the parameter to a const reference to get rid of
it.

* Optimize translation file loader

Use "std::string::append" when calculating the final index
for the translation table to avoid unnecessary temporary
strings. This speeds the translation file loader up
significantly as std::string uses heap allocation which
tends to be rather slow. Additionally, the heap is no
longer being littered by these unnecessary string
temporaries, increasing performance of code that gets
executed after the translation file loader finishes.

* Optimize server map saving

When the directory structure for the world data is created
during server map saving, an unnecessary value passing of
the directory name slows things down. Remove that overhead
by converting the offending parameter to a const reference.
2019-05-18 17:19:13 +02:00
..
meshgen Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
render Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
activeobjectmgr.cpp Add an activeobject manager to hold active objects (#7939) 2018-12-13 20:18:54 +01:00
activeobjectmgr.h Add an activeobject manager to hold active objects (#7939) 2018-12-13 20:18:54 +01:00
camera.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
camera.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
client.cpp Remove unnecessary CSM warning (#8485) 2019-04-28 00:44:26 +01:00
client.h Fix particle spawners not visible since CSM spawner implementation (#8289) 2019-03-01 20:16:11 +01:00
clientenvironment.cpp Consistent HP and damage types (#8167) 2019-02-10 23:03:26 +00:00
clientenvironment.h Consistent HP and damage types (#8167) 2019-02-10 23:03:26 +00:00
clientevent.h Fix particle spawners not visible since CSM spawner implementation (#8289) 2019-03-01 20:16:11 +01:00
clientlauncher.cpp Fix cloud color in loading screen and main menu (#8174) 2019-02-04 19:11:02 +00:00
clientlauncher.h C++ modernize: Pragma once (#6264) 2017-08-17 22:19:39 +02:00
clientmap.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
clientmap.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
clientmedia.cpp Fix clang tidy error due to incorrect use of quotes for character 2019-03-06 14:41:37 +00:00
clientmedia.h Remove remote media compatibility mode. (#8044) 2019-01-04 00:26:08 +01:00
clientobject.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
clientobject.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
clouds.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
clouds.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
CMakeLists.txt Add an activeobject manager to hold active objects (#7939) 2018-12-13 20:18:54 +01:00
content_cao.cpp Optimize string (mis)handling (#8128) 2019-05-18 17:19:13 +02:00
content_cao.h Optimize string (mis)handling (#8128) 2019-05-18 17:19:13 +02:00
content_cso.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
content_cso.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
content_mapblock.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
content_mapblock.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
event_manager.h Client eventmanager refactor (#7179) 2018-03-30 18:32:52 +02:00
filecache.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
filecache.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
fontengine.cpp Fix crash if display resolution is not set (#7950) 2018-12-08 16:26:04 +01:00
fontengine.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
game.cpp Use player as starting point instead of camera when pointing node (#8261) 2019-04-27 12:44:56 +02:00
game.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
gameui.cpp Improve readability of debug menu by using '|' (#8488) 2019-04-27 12:45:44 +02:00
gameui.h Fix GameUI flag value regression introduced by a78659ed0529226ad937f5e241ad72ba93702959 2018-05-29 08:34:09 +02:00
guiscalingfilter.cpp Optimize string (mis)handling (#8128) 2019-05-18 17:19:13 +02:00
guiscalingfilter.h Optimize string (mis)handling (#8128) 2019-05-18 17:19:13 +02:00
hud.cpp Optimize string (mis)handling (#8128) 2019-05-18 17:19:13 +02:00
hud.h Optimize string (mis)handling (#8128) 2019-05-18 17:19:13 +02:00
imagefilters.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
imagefilters.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
inputhandler.cpp Extend pitch fly mode to swimming (#7943) 2018-12-31 00:07:30 +00:00
inputhandler.h Game refactor [4/X]: keycache is now owned by InputHandler 2018-01-20 16:38:38 +01:00
joystick_controller.cpp Move files to subdirectories (#6599) 2017-11-08 23:56:20 +01:00
joystick_controller.h Fix some gcc 7.3 reported warnings 2018-03-23 22:12:48 +01:00
keycode.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
keycode.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
keys.h Extend pitch fly mode to swimming (#7943) 2018-12-31 00:07:30 +00:00
localplayer.cpp Slippery: Do not apply when swimming (#8198) 2019-02-10 17:04:04 +01:00
localplayer.h Extend pitch fly mode to swimming (#7943) 2018-12-31 00:07:30 +00:00
mapblock_mesh.cpp Fix texture rotation for wallmounted nodeboxes 2019-03-19 22:36:51 +01:00
mapblock_mesh.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
mesh_generator_thread.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
mesh_generator_thread.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
mesh.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
mesh.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
minimap.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
minimap.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
particles.cpp Fix particle spawners not visible since CSM spawner implementation (#8289) 2019-03-01 20:16:11 +01:00
particles.h Fix particle spawners not visible since CSM spawner implementation (#8289) 2019-03-01 20:16:11 +01:00
renderingengine.cpp Fix crash if display resolution is not set (#7950) 2018-12-08 16:26:04 +01:00
renderingengine.h Provide Xorg/net wm process ID (#7445) 2018-06-17 10:41:07 +02:00
shader.cpp Require 'waving = 3' in a nodedef to apply the liquid waving shader (#8418) 2019-03-27 00:18:43 +00:00
shader.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
sky.cpp Draw all horizons and sky base, in front of stars (#7932) 2018-12-06 03:56:35 +00:00
sky.h Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
sound_openal.cpp Make sounds stop playing when entering game or mainmenu 2018-03-24 16:05:26 +01:00
sound_openal.h Cleanup sound manager class (#7158) 2018-03-24 15:45:25 +01:00
sound.cpp Cleanup sound manager class (#7158) 2018-03-24 15:45:25 +01:00
sound.h Cleanup sound manager class (#7158) 2018-03-24 15:45:25 +01:00
tile.cpp Optimize string (mis)handling (#8128) 2019-05-18 17:19:13 +02:00
tile.h Require 'waving = 3' in a nodedef to apply the liquid waving shader (#8418) 2019-03-27 00:18:43 +00:00
wieldmesh.cpp Fix more transparency issues with ogles2 driver (#8005) 2018-12-20 23:40:17 +01:00
wieldmesh.h Add object visual type 'item' (#7870) 2018-12-11 02:57:04 +00:00