Skip to content

Commit ce98022

Browse files
authoredMay 20, 2017
Various code cleanup & little performance improvement on HTTP download (#5772)
* Disable or remove unused enum members/functions * Tiny code style fixes * Make some functions const * Replace ClientMediaDownloader std::unordered_map with std::map
1 parent 3526740 commit ce98022

15 files changed

+18
-85
lines changed
 

Diff for: ‎src/activeobject.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ enum ActiveObjectType {
2828
ACTIVEOBJECT_TYPE_TEST = 1,
2929
// Deprecated stuff
3030
ACTIVEOBJECT_TYPE_ITEM = 2,
31-
ACTIVEOBJECT_TYPE_RAT = 3,
32-
ACTIVEOBJECT_TYPE_OERKKI1 = 4,
33-
ACTIVEOBJECT_TYPE_FIREFLY = 5,
31+
// ACTIVEOBJECT_TYPE_RAT = 3,
32+
// ACTIVEOBJECT_TYPE_OERKKI1 = 4,
33+
// ACTIVEOBJECT_TYPE_FIREFLY = 5,
3434
ACTIVEOBJECT_TYPE_MOBV2 = 6,
3535
// End deprecated stuff
3636
ACTIVEOBJECT_TYPE_LUAENTITY = 7,

Diff for: ‎src/camera.h

+2-18
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,6 @@ class Camera
6464
Client *client);
6565
~Camera();
6666

67-
// Get player scene node.
68-
// This node is positioned at the player's torso (without any view bobbing),
69-
// as given by Player::m_position. Yaw is applied but not pitch.
70-
inline scene::ISceneNode* getPlayerNode() const
71-
{
72-
return m_playernode;
73-
}
74-
75-
// Get head scene node.
76-
// It has the eye transformation and pitch applied,
77-
// but no view bobbing.
78-
inline scene::ISceneNode* getHeadNode() const
79-
{
80-
return m_headnode;
81-
}
82-
8367
// Get camera scene node.
8468
// It has the eye transformation, pitch and view bobbing applied.
8569
inline scene::ICameraSceneNode* getCameraNode() const
@@ -160,13 +144,13 @@ class Camera
160144
else
161145
m_camera_mode = CAMERA_MODE_FIRST;
162146
}
163-
147+
164148
// Set the current camera mode
165149
inline void setCameraMode(CameraMode mode)
166150
{
167151
m_camera_mode = mode;
168152
}
169-
153+
170154
//read the current camera mode
171155
inline CameraMode getCameraMode()
172156
{

Diff for: ‎src/chat.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ u32 ChatBuffer::getLineCount() const
7777
return m_unformatted.size();
7878
}
7979

80-
u32 ChatBuffer::getScrollback() const
81-
{
82-
return m_scrollback;
83-
}
84-
8580
const ChatLine& ChatBuffer::getLine(u32 index) const
8681
{
8782
assert(index < getLineCount()); // pre-condition

Diff for: ‎src/chat.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ class ChatBuffer
8686

8787
// Get number of lines currently in buffer.
8888
u32 getLineCount() const;
89-
// Get scrollback size, maximum number of lines in buffer.
90-
u32 getScrollback() const;
9189
// Get reference to i-th chat line.
9290
const ChatLine& getLine(u32 index) const;
9391

@@ -162,8 +160,7 @@ class ChatPrompt
162160
std::wstring getLine() const { return m_line; }
163161

164162
// Get section of line that is currently selected
165-
std::wstring getSelection() const
166-
{ return m_line.substr(m_cursor, m_cursor_len); }
163+
std::wstring getSelection() const { return m_line.substr(m_cursor, m_cursor_len); }
167164

168165
// Clear the current line
169166
void clear();

Diff for: ‎src/client.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ float Client::getRTT()
17231723

17241724
float Client::getCurRate()
17251725
{
1726-
return ( m_con.getLocalStat(con::CUR_INC_RATE) +
1726+
return (m_con.getLocalStat(con::CUR_INC_RATE) +
17271727
m_con.getLocalStat(con::CUR_DL_RATE));
17281728
}
17291729

Diff for: ‎src/client.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
467467
Minimap* getMinimap() { return m_minimap; }
468468
void setCamera(Camera* camera) { m_camera = camera; }
469469

470-
Camera* getCamera ()
471-
{ return m_camera; }
470+
Camera* getCamera () { return m_camera; }
472471

473472
bool shouldShowMinimap() const;
474473

Diff for: ‎src/clientiface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
590590
}
591591
}
592592

593-
u32 RemoteClient::uptime()
593+
u32 RemoteClient::uptime() const
594594
{
595595
return porting::getTime(PRECISION_SECONDS) - m_connection_time;
596596
}

Diff for: ‎src/clientiface.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class RemoteClient
345345
{ serialization_version = m_pending_serialization_version; }
346346

347347
/* get uptime */
348-
u32 uptime();
348+
u32 uptime() const;
349349

350350
/* set version information */
351351
void setVersionInfo(u8 major, u8 minor, u8 patch, const std::string &full)
@@ -360,7 +360,6 @@ class RemoteClient
360360
u8 getMajor() const { return m_version_major; }
361361
u8 getMinor() const { return m_version_minor; }
362362
u8 getPatch() const { return m_version_patch; }
363-
std::string getVersion() const { return m_full_version; }
364363
private:
365364
// Version is stored in here after INIT before INIT2
366365
u8 m_pending_serialization_version;

Diff for: ‎src/clientmedia.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ void ClientMediaDownloader::remoteMediaReceived(
348348

349349
std::string name;
350350
{
351-
std::map<unsigned long, std::string>::iterator it =
351+
UNORDERED_MAP<unsigned long, std::string>::iterator it =
352352
m_remote_file_transfers.find(fetch_result.request_id);
353353
assert(it != m_remote_file_transfers.end());
354354
name = it->second;

Diff for: ‎src/clientmedia.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2626
#include <map>
2727
#include <set>
2828
#include <vector>
29+
#include "util/cpp11_container.h"
2930

3031
class Client;
3132
struct HTTPFetchResult;
@@ -137,7 +138,7 @@ class ClientMediaDownloader
137138
s32 m_httpfetch_active;
138139
s32 m_httpfetch_active_limit;
139140
s32 m_outstanding_hash_sets;
140-
std::map<unsigned long, std::string> m_remote_file_transfers;
141+
UNORDERED_MAP<unsigned long, std::string> m_remote_file_transfers;
141142

142143
// All files up to this name have either been received from a
143144
// remote server or failed on all remote servers, so those files

Diff for: ‎src/clientobject.h

+5-10
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,13 @@ class ClientActiveObject : public ActiveObject
4949
virtual aabb3f *getSelectionBox() { return NULL; }
5050
virtual bool getCollisionBox(aabb3f *toset) const { return false; }
5151
virtual bool collideWithObjects() const { return false; }
52-
virtual v3f getPosition(){return v3f(0,0,0);}
53-
virtual float getYaw() const {return 0;}
54-
virtual scene::ISceneNode *getSceneNode(){return NULL;}
55-
virtual scene::IMeshSceneNode *getMeshSceneNode(){return NULL;}
56-
virtual scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode(){return NULL;}
57-
virtual WieldMeshSceneNode *getWieldMeshSceneNode(){return NULL;}
58-
virtual scene::IBillboardSceneNode *getSpriteSceneNode(){return NULL;}
59-
virtual bool isPlayer() const {return false;}
52+
virtual v3f getPosition(){ return v3f(0,0,0); }
53+
virtual float getYaw() const { return 0; }
54+
virtual scene::ISceneNode *getSceneNode() { return NULL; }
55+
virtual scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode() { return NULL; }
6056
virtual bool isLocalPlayer() const {return false;}
61-
virtual void setAttachments(){}
57+
virtual void setAttachments() {}
6258
virtual bool doShowSelectionBox(){return true;}
63-
virtual void updateCameraOffset(v3s16 camera_offset){};
6459

6560
// Step object in time
6661
virtual void step(float dtime, ClientEnvironment *env){}

Diff for: ‎src/content_cao.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -706,26 +706,11 @@ scene::ISceneNode* GenericCAO::getSceneNode()
706706
return NULL;
707707
}
708708

709-
scene::IMeshSceneNode* GenericCAO::getMeshSceneNode()
710-
{
711-
return m_meshnode;
712-
}
713-
714709
scene::IAnimatedMeshSceneNode* GenericCAO::getAnimatedMeshSceneNode()
715710
{
716711
return m_animated_meshnode;
717712
}
718713

719-
WieldMeshSceneNode* GenericCAO::getWieldMeshSceneNode()
720-
{
721-
return m_wield_meshnode;
722-
}
723-
724-
scene::IBillboardSceneNode* GenericCAO::getSpriteSceneNode()
725-
{
726-
return m_spritenode;
727-
}
728-
729714
void GenericCAO::setChildrenVisible(bool toset)
730715
{
731716
for (std::vector<u16>::size_type i = 0; i < m_children.size(); i++) {

Diff for: ‎src/content_cao.h

-11
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,8 @@ class GenericCAO : public ClientActiveObject
146146

147147
scene::ISceneNode *getSceneNode();
148148

149-
scene::IMeshSceneNode *getMeshSceneNode();
150-
151149
scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode();
152150

153-
WieldMeshSceneNode *getWieldMeshSceneNode();
154-
155-
scene::IBillboardSceneNode *getSpriteSceneNode();
156-
157-
inline bool isPlayer() const
158-
{
159-
return m_is_player;
160-
}
161-
162151
inline bool isLocalPlayer() const
163152
{
164153
return m_is_local_player;

Diff for: ‎src/nodedef.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,6 @@ class CNodeDefManager: public IWritableNodeDefManager {
881881
void serialize(std::ostream &os, u16 protocol_version) const;
882882
void deSerialize(std::istream &is);
883883

884-
inline virtual bool getNodeRegistrationStatus() const;
885884
inline virtual void setNodeRegistrationStatus(bool completed);
886885

887886
virtual void pendNodeResolve(NodeResolver *nr);
@@ -1805,13 +1804,6 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
18051804
}
18061805
}
18071806

1808-
1809-
inline bool CNodeDefManager::getNodeRegistrationStatus() const
1810-
{
1811-
return m_node_registration_complete;
1812-
}
1813-
1814-
18151807
inline void CNodeDefManager::setNodeRegistrationStatus(bool completed)
18161808
{
18171809
m_node_registration_complete = completed;

Diff for: ‎src/nodedef.h

-3
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,6 @@ class INodeDefManager {
432432

433433
virtual void serialize(std::ostream &os, u16 protocol_version) const=0;
434434

435-
virtual bool getNodeRegistrationStatus() const=0;
436-
437435
virtual void pendNodeResolve(NodeResolver *nr)=0;
438436
virtual bool cancelNodeResolveCallback(NodeResolver *nr)=0;
439437
virtual bool nodeboxConnects(const MapNode from, const MapNode to, u8 connect_face)=0;
@@ -491,7 +489,6 @@ class IWritableNodeDefManager : public INodeDefManager {
491489
virtual void serialize(std::ostream &os, u16 protocol_version) const=0;
492490
virtual void deSerialize(std::istream &is)=0;
493491

494-
virtual bool getNodeRegistrationStatus() const=0;
495492
virtual void setNodeRegistrationStatus(bool completed)=0;
496493

497494
virtual void pendNodeResolve(NodeResolver *nr)=0;

0 commit comments

Comments
 (0)
Please sign in to comment.