comparison open.cpp @ 430:2d14d21f826b api-inversion

Make the keys std::set in adb_t a std::map instead. The key's index can usefully be the value, and now suddenly we can remove audioDB::getKeyPos and its oh-so-helpful "this should be an STL map" comment.
author mas01cr
date Wed, 24 Dec 2008 10:55:36 +0000
parents ad2206c24986
children 62a0515f59be
comparison
equal deleted inserted replaced
429:5893ec2ec246 430:2d14d21f826b
28 28
29 if(adb->header->length > 0) { 29 if(adb->header->length > 0) {
30 unsigned nfiles = adb->header->numFiles; 30 unsigned nfiles = adb->header->numFiles;
31 key_table_length = ALIGN_PAGE_UP(nfiles * O2_FILETABLE_ENTRY_SIZE); 31 key_table_length = ALIGN_PAGE_UP(nfiles * O2_FILETABLE_ENTRY_SIZE);
32 mmap_or_goto_error(char *, key_table, adb->header->fileTableOffset, key_table_length); 32 mmap_or_goto_error(char *, key_table, adb->header->fileTableOffset, key_table_length);
33 for (unsigned i = 0; i < nfiles; i++) { 33 for (unsigned int k = 0; k < nfiles; k++) {
34 adb->keys->insert(key_table + i*O2_FILETABLE_ENTRY_SIZE); 34 (*adb->keys)[(key_table + k*O2_FILETABLE_ENTRY_SIZE)] = k;
35 } 35 }
36 munmap(key_table, key_table_length); 36 munmap(key_table, key_table_length);
37 } 37 }
38 38
39 return 0; 39 return 0;
77 } 77 }
78 if(!audiodb_check_header(adb->header)) { 78 if(!audiodb_check_header(adb->header)) {
79 goto error; 79 goto error;
80 } 80 }
81 81
82 adb->keys = new std::set<std::string>; 82 adb->keys = new std::map<std::string,uint32_t>;
83 if(!adb->keys) { 83 if(!adb->keys) {
84 goto error; 84 goto error;
85 } 85 }
86 if(audiodb_collect_keys(adb)) { 86 if(audiodb_collect_keys(adb)) {
87 goto error; 87 goto error;