mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 14:01:20 -03:00
Apply new indentation, brace, and whitespace style
This commit is contained in:
36
intern.cpp
36
intern.cpp
@@ -21,9 +21,11 @@
|
||||
#include "intern.h"
|
||||
|
||||
/** Comparison function for intern'd strings */
|
||||
class string_table_compare_t {
|
||||
public:
|
||||
bool operator()(const wchar_t *a, const wchar_t *b) const {
|
||||
class string_table_compare_t
|
||||
{
|
||||
public:
|
||||
bool operator()(const wchar_t *a, const wchar_t *b) const
|
||||
{
|
||||
return wcscmp(a, b) < 0;
|
||||
}
|
||||
};
|
||||
@@ -43,10 +45,10 @@ static string_table_t string_table;
|
||||
/** The lock to provide thread safety for intern'd strings */
|
||||
static pthread_mutex_t intern_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static const wchar_t *intern_with_dup( const wchar_t *in, bool dup )
|
||||
static const wchar_t *intern_with_dup(const wchar_t *in, bool dup)
|
||||
{
|
||||
if( !in )
|
||||
return NULL;
|
||||
if (!in)
|
||||
return NULL;
|
||||
|
||||
// debug( 0, L"intern %ls", in );
|
||||
scoped_lock lock(intern_lock);
|
||||
@@ -54,17 +56,23 @@ static const wchar_t *intern_with_dup( const wchar_t *in, bool dup )
|
||||
|
||||
#if USE_SET
|
||||
string_table_t::const_iterator iter = string_table.find(in);
|
||||
if (iter != string_table.end()) {
|
||||
if (iter != string_table.end())
|
||||
{
|
||||
result = *iter;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dup ? wcsdup(in) : in;
|
||||
string_table.insert(result);
|
||||
}
|
||||
#else
|
||||
string_table_t::iterator iter = std::lower_bound(string_table.begin(), string_table.end(), in, string_table_compare_t());
|
||||
if (iter != string_table.end() && wcscmp(*iter, in) == 0) {
|
||||
if (iter != string_table.end() && wcscmp(*iter, in) == 0)
|
||||
{
|
||||
result = *iter;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dup ? wcsdup(in) : in;
|
||||
string_table.insert(iter, result);
|
||||
}
|
||||
@@ -72,13 +80,13 @@ static const wchar_t *intern_with_dup( const wchar_t *in, bool dup )
|
||||
return result;
|
||||
}
|
||||
|
||||
const wchar_t *intern( const wchar_t *in )
|
||||
const wchar_t *intern(const wchar_t *in)
|
||||
{
|
||||
return intern_with_dup(in, true);
|
||||
return intern_with_dup(in, true);
|
||||
}
|
||||
|
||||
|
||||
const wchar_t *intern_static( const wchar_t *in )
|
||||
const wchar_t *intern_static(const wchar_t *in)
|
||||
{
|
||||
return intern_with_dup(in, false);
|
||||
return intern_with_dup(in, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user