Avoid returning references that are mutex protected (#297)
* Fix unsafe calls and safeguard WebSocketMessage from being called w/ temporaries * Use unnamed namespace to express internal linkage * Avoid returning references that are mutex protected Motivation for this MR The antipattern of returning references to mutex protected members was removed. Since a caller can hold the reference it would make all class level locking meaningless. Instead values are returned. The IXWebSocketPerMessageDeflateOptions class was shrunk by 7 bytes (1 padding + 2*3) after changing the int members to the used uint8_t; side effects of that were handled. An inefficient "string -> int" was replaced by standard library. As seen here http://coliru.stacked-crooked.com/a/46b5990bafb9c626 this gives an order of magnitude better performance.
This commit is contained in:
@ -39,8 +39,8 @@ namespace ix
|
||||
bool _enabled;
|
||||
bool _clientNoContextTakeover;
|
||||
bool _serverNoContextTakeover;
|
||||
int _clientMaxWindowBits;
|
||||
int _serverMaxWindowBits;
|
||||
uint8_t _clientMaxWindowBits;
|
||||
uint8_t _serverMaxWindowBits;
|
||||
|
||||
void sanitizeClientMaxWindowBits();
|
||||
};
|
||||
|
Reference in New Issue
Block a user