[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/dic compdic.cpp header.cpp
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot/dic compdic.cpp header.cpp |
Date: |
Sat, 13 Jun 2009 21:44:06 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 09/06/13 21:44:06
Modified files:
dic : compdic.cpp header.cpp
Log message:
Simplified code a little
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/compdic.cpp?cvsroot=eliot&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/header.cpp?cvsroot=eliot&r1=1.4&r2=1.5
Patches:
Index: compdic.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/compdic.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- compdic.cpp 1 May 2009 09:04:47 -0000 1.9
+++ compdic.cpp 13 Jun 2009 21:44:05 -0000 1.10
@@ -69,9 +69,7 @@
using namespace std;
-//#define DEBUG_LIST
//#define DEBUG_OUTPUT
-//#define DEBUG_OUTPUT_L2
#define CHECK_RECURSION
@@ -214,7 +212,7 @@
}
-// Change endianness of the pointes edges, and write them to the given ostream
+// Change endianness of the pointed edges, and write them to the given ostream
void write_node(uint32_t *ioEdges, unsigned int num, ostream &outfile)
{
// Handle endianness
@@ -227,11 +225,6 @@
printf("writing %d edges\n", num);
for (int i = 0; i < num; i++)
{
-#ifdef DEBUG_OUTPUT_L2
- printf("ptr=%2d t=%d l=%d chr=%2d (%c)\n",
- ioEdges[i].ptr, ioEdges[i].term, ioEdges[i].last,
- ioEdges[i].chr, ioEdges[i].chr -1 +'a');
-#endif
outfile.write((char*)(ioEdges + i), sizeof(DicEdge));
}
#else
@@ -278,10 +271,10 @@
int max_rec = 0;
#endif
-/* global variables */
typedef boost::unordered_map<vector<DicEdge>, unsigned int> HashMap;
-HashMap *global_hashmap;
+/* global variables */
+HashMap global_hashmap;
wchar_t global_stringbuf[MAX_STRING_LENGTH]; /* Space for current string */
wchar_t* global_endstring; /* Marks END of current string */
@@ -374,8 +367,8 @@
// Mark the last edge
edges.back().last = 1;
- HashMap::const_iterator itMap = global_hashmap->find(edges);
- if (itMap != global_hashmap->end())
+ HashMap::const_iterator itMap = global_hashmap.find(edges);
+ if (itMap != global_hashmap.end())
{
ioHeaderInfo.edgessaved += numedges;
ioHeaderInfo.nodessaved++;
@@ -385,7 +378,7 @@
else
{
unsigned int node_pos = ioHeaderInfo.edgesused;
- (*global_hashmap)[edges] = ioHeaderInfo.edgesused;
+ global_hashmap[edges] = ioHeaderInfo.edgesused;
ioHeaderInfo.edgesused += numedges;
ioHeaderInfo.nodesused++;
write_node(reinterpret_cast<uint32_t*>(&edges.front()),
@@ -531,8 +524,6 @@
global_input = uncompressed;
global_endofinput = global_input + dicsize;
- global_hashmap = new HashMap();
-
headerInfo.dawg = true;
Header tempHeader = skip_init_header(outfile, headerInfo);
@@ -561,7 +552,6 @@
Header aHeader(headerInfo);
aHeader.print();
- delete global_hashmap;
delete[] uncompressed;
outfile.close();
Index: header.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/header.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- header.cpp 22 Nov 2008 13:11:48 -0000 1.4
+++ header.cpp 13 Jun 2009 21:44:05 -0000 1.5
@@ -49,22 +49,7 @@
#include "dic_exception.h"
-// Note: swap4 is duplicated in dic.cpp
#if defined(WORDS_BIGENDIAN)
-static uint32_t swap4(uint32_t v)
-{
- uint32_t r;
- uint8_t *pv = (uint8_t*)&v;
- uint8_t *pr = (uint8_t*)&r;
-
- pr[0] = pv[3];
- pr[1] = pv[2];
- pr[2] = pv[1];
- pr[3] = pv[0];
-
- return r;
-}
-
// Nothing to do on big-endian machines
# define ntohll(x) (x)
# define htonll(x) (x)
- [Eliot-dev] eliot/dic compdic.cpp header.cpp,
Olivier Teulière <=