summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/common.h6
-rw-r--r--src/common/fixed_size_queue.h70
-rw-r--r--src/common/string_util.cpp11
4 files changed, 8 insertions, 80 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 868fda55e..3a82f5b80 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -38,7 +38,6 @@ set(HEADERS
38 fifo_queue.h 38 fifo_queue.h
39 file_search.h 39 file_search.h
40 file_util.h 40 file_util.h
41 fixed_size_queue.h
42 hash.h 41 hash.h
43 linear_disk_cache.h 42 linear_disk_cache.h
44 log.h 43 log.h
diff --git a/src/common/common.h b/src/common/common.h
index cb69eabe4..9f3016d34 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -20,11 +20,6 @@
20 20
21#define STACKALIGN 21#define STACKALIGN
22 22
23#if __cplusplus >= 201103L || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__)
24#define HAVE_CXX11_SYNTAX 1
25#endif
26
27#if HAVE_CXX11_SYNTAX
28// An inheritable class to disallow the copy constructor and operator= functions 23// An inheritable class to disallow the copy constructor and operator= functions
29class NonCopyable 24class NonCopyable
30{ 25{
@@ -36,7 +31,6 @@ private:
36 NonCopyable(NonCopyable&); 31 NonCopyable(NonCopyable&);
37 NonCopyable& operator=(NonCopyable& other); 32 NonCopyable& operator=(NonCopyable& other);
38}; 33};
39#endif
40 34
41#include "common/log.h" 35#include "common/log.h"
42#include "common/common_types.h" 36#include "common/common_types.h"
diff --git a/src/common/fixed_size_queue.h b/src/common/fixed_size_queue.h
deleted file mode 100644
index 1e3a5dea6..000000000
--- a/src/common/fixed_size_queue.h
+++ /dev/null
@@ -1,70 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7// STL-look-a-like interface, but name is mixed case to distinguish it clearly from the
8// real STL classes.
9
10// Not fully featured, no safety checking yet. Add features as needed.
11
12// TODO: "inline" storage?
13
14template <class T, int N>
15class fixed_size_queue.h
16{
17 T *storage;
18 int head;
19 int tail;
20 int count; // sacrifice 4 bytes for a simpler implementation. may optimize away in the future.
21
22 // Make copy constructor private for now.
23 fixed_size_queue.h(fixed_size_queue.h &other) { }
24
25public:
26 fixed_size_queue.h()
27 {
28 storage = new T[N];
29 clear();
30 }
31
32 ~fixed_size_queue.h()
33 {
34 delete [] storage;
35 }
36
37 void clear() {
38 head = 0;
39 tail = 0;
40 count = 0;
41 }
42
43 void push(T t) {
44 storage[tail] = t;
45 tail++;
46 if (tail == N)
47 tail = 0;
48 count++;
49 }
50
51 void pop() {
52 head++;
53 if (head == N)
54 head = 0;
55 count--;
56 }
57
58 T pop_front() {
59 const T &temp = storage[head];
60 pop();
61 return temp;
62 }
63
64 T &front() { return storage[head]; }
65 const T &front() const { return storage[head]; }
66
67 size_t size() const {
68 return count;
69 }
70};
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index a3c7f479e..b0c65d47d 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -279,12 +279,17 @@ std::string TabsToSpaces(int tab_size, const std::string &in)
279 279
280std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) 280std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest)
281{ 281{
282 while(1) 282 size_t pos = 0;
283
284 if (src == dest)
285 return result;
286
287 while ((pos = result.find(src, pos)) != std::string::npos)
283 { 288 {
284 size_t pos = result.find(src);
285 if (pos == std::string::npos) break;
286 result.replace(pos, src.size(), dest); 289 result.replace(pos, src.size(), dest);
290 pos += dest.length();
287 } 291 }
292
288 return result; 293 return result;
289} 294}
290 295