Skip to content

Commit

Permalink
[WIP] Rename variable and function
Browse files Browse the repository at this point in the history
  • Loading branch information
ma8ma committed Mar 14, 2019
1 parent 5a2ee2f commit 5c4dd31
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 104 deletions.
12 changes: 6 additions & 6 deletions src/article/layouttree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ LayoutTree::LayoutTree( const std::string& url, const bool show_abone, const boo
#ifdef _DEBUG
std::cout << "LayoutTree::LayoutTree : url = " << url << " show_abone = " << m_show_abone << std::endl;
#endif
m_vec_header.reserve( kExpectedResNumber ) ;
m_header_map.reserve( kExpectedResNumber ) ;
m_article = DBTREE::get_article( m_url );
assert( m_article );

Expand All @@ -89,7 +89,7 @@ void LayoutTree::clear()
{
m_heap.clear();

m_vec_header.clear();
m_header_map.clear();

m_last_header = NULL;
m_max_res_number = 0;
Expand Down Expand Up @@ -326,7 +326,7 @@ void LayoutTree::append_node( DBTREE::NODE* node_header, const bool joint )
header->res_number = res_number;
header->node = node_header;
if( res_number > m_max_res_number ) m_max_res_number = res_number;
m_vec_header[ res_number ] = header;
m_header_map[ res_number ] = header;

while( dom ){
m_last_dom_attr = dom->attr;
Expand Down Expand Up @@ -474,7 +474,7 @@ void LayoutTree::append_abone_node( DBTREE::NODE* node_header )
if( ! m_show_abone && m_article->get_abone_transparent() ) return;

LAYOUT* head = create_layout_header();
m_vec_header[ res_number ] = head;
m_header_map[ res_number ] = head;

head->res_number = res_number;

Expand Down Expand Up @@ -554,10 +554,10 @@ const LAYOUT* LayoutTree::get_header_of_res_const( const int number ){ return ge

LAYOUT* LayoutTree::get_header_of_res( const int number )
{
if( m_vec_header.empty() || !m_vec_header.count( number ) ) return NULL;
if( m_header_map.empty() || !m_header_map.count( number ) ) return nullptr;
if( number > m_max_res_number || number <= 0 ) return NULL;

return m_vec_header[ number ];
return m_header_map[ number ];
}


Expand Down
2 changes: 1 addition & 1 deletion src/article/layouttree.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace ARTICLE
JDLIB::HEAP m_heap;
std::string m_url;

std::unordered_map< int, LAYOUT* > m_vec_header; // ヘッダのポインタの配列
std::unordered_map< int, LAYOUT* > m_header_map; // ヘッダのポインタのハッシュマップ

// コメントノードやプレビュー表示時に使うローカルなノードツリー
DBTREE::NodeTreeBase* m_local_nodetree;
Expand Down
2 changes: 1 addition & 1 deletion src/article/preference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Preferences::Preferences( Gtk::Window* parent, const std::string& url, const std
m_edit_id.set_text( str_id );
// あぼーんレス番号
// 連番は 12-34 の様なフォーマットに変換
const std::unordered_set< int >& set_res = DBTREE::get_abone_vec_res( get_url() );
const std::unordered_set< int >& set_res = DBTREE::get_abone_reses( get_url() );
// レス番号をソートする
const std::set< int > tmp_set{ set_res.begin(), set_res.end() };
int pre_res = 0;
Expand Down
124 changes: 62 additions & 62 deletions src/dbtree/articlebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ ArticleBase::ArticleBase( const std::string& datbase, const std::string& id, boo
// std::cout << "ArticleBase::ArticleBase : " << m_id << std::endl;
#endif

m_vec_abone_res.reserve( kExpectedResInfo );
m_vec_bookmark.reserve( kExpectedResInfo );
m_vec_posted.reserve( kExpectedResInfo );
m_abone_reses.reserve( kExpectedResInfo );
m_bookmarks.reserve( kExpectedResInfo );
m_posts.reserve( kExpectedResInfo );

memset( &m_access_time, 0, sizeof( struct timeval ) );
memset( &m_check_update_time, 0, sizeof( struct timeval ) );
Expand Down Expand Up @@ -574,7 +574,7 @@ void ArticleBase::update_writetime()
//
int ArticleBase::get_num_posted()
{
return m_vec_posted.size();
return m_posts.size();
}


Expand Down Expand Up @@ -662,7 +662,7 @@ void ArticleBase::update_abone()
// nodetreeが作られていないときは更新しない
if( ! m_nodetree ) return;

get_nodetree()->copy_abone_info( m_list_abone_id, m_list_abone_name, m_list_abone_word, m_list_abone_regex, m_vec_abone_res,
get_nodetree()->copy_abone_info( m_list_abone_id, m_list_abone_name, m_list_abone_word, m_list_abone_regex, m_abone_reses,
m_abone_transparent, m_abone_chain, m_abone_age, m_abone_board, m_abone_global );

get_nodetree()->update_abone_all();
Expand Down Expand Up @@ -706,10 +706,10 @@ void ArticleBase::reset_abone( const std::list< std::string >& ids,

for( int i = 1; i <= MIN( m_number_load, (int)vec_abone_res.size() ) ; ++i ){
if( vec_abone_res[ i ] ) {
m_vec_abone_res.insert( i );
m_abone_reses.insert( i );
}
else {
m_vec_abone_res.erase( i );
m_abone_reses.erase( i );
}
}
}
Expand Down Expand Up @@ -804,10 +804,10 @@ void ArticleBase::set_abone_res( const int num_from, const int num_to, const boo
#endif

if( set ) {
for( int i = num_from; i <= num_to; ++i ) m_vec_abone_res.insert( i );
for( int i = num_from; i <= num_to; ++i ) m_abone_reses.insert( i );
}
else {
for( int i = num_from; i <= num_to; ++i ) m_vec_abone_res.erase( i );
for( int i = num_from; i <= num_to; ++i ) m_abone_reses.erase( i );
}

update_abone();
Expand Down Expand Up @@ -897,7 +897,7 @@ void ArticleBase::set_abone_global( const bool set )
//
int ArticleBase::get_num_bookmark()
{
return m_vec_bookmark.size();
return m_bookmarks.size();
}


Expand All @@ -906,7 +906,7 @@ int ArticleBase::get_num_bookmark()
//
bool ArticleBase::is_bookmarked( const int number )
{
return ( m_vec_bookmark.find( number ) != m_vec_bookmark.end() );
return ( m_bookmarks.find( number ) != m_bookmarks.end() );
}


Expand All @@ -915,15 +915,15 @@ bool ArticleBase::is_bookmarked( const int number )
//
void ArticleBase::set_bookmark( const int number, const bool set )
{
if( m_vec_bookmark.empty() ) get_nodetree();
if( m_bookmarks.empty() ) get_nodetree();
if( number <= 0 || number > kMaxResNumber ) return;

m_save_info = true;
if( set ) {
m_vec_bookmark.insert( number );
m_bookmarks.insert( number );
}
else {
m_vec_bookmark.erase( number );
m_bookmarks.erase( number );
}
}

Expand All @@ -933,7 +933,7 @@ void ArticleBase::set_bookmark( const int number, const bool set )
//
bool ArticleBase::is_posted( const int number )
{
return ( m_vec_posted.find( number ) != m_vec_posted.end() );
return ( m_posts.find( number ) != m_posts.end() );
}


Expand All @@ -950,14 +950,14 @@ void ArticleBase::set_posted( const int number, const bool set )
if( number <= 0 || number > m_number_load ) return;

// まだnodetreeが作られてなくて情報が得られてないのでnodetreeを作って情報取得
if( m_vec_posted.empty() ) get_nodetree();
if( m_posts.empty() ) get_nodetree();

m_save_info = true;
if( set ) {
m_vec_posted.insert( number );
m_posts.insert( number );
}
else {
m_vec_posted.erase( number );
m_posts.erase( number );
}

// nodetreeに情報反映
Expand All @@ -972,14 +972,14 @@ void ArticleBase::clear_post_history()
if( ! is_cached() ) return;

read_info();
if( !m_vec_posted.empty() || m_write_time.tv_sec || m_write_time.tv_usec ){
if( !m_posts.empty() || m_write_time.tv_sec || m_write_time.tv_usec ){

#ifdef _DEBUG
std::cout << "ArticleBase::clear_post_history size = " << m_vec_posted.size()
std::cout << "ArticleBase::clear_post_history size = " << m_posts.size()
<< " time = " << m_write_time_date
<< " subject = " << m_subject << std::endl;
#endif
m_vec_posted.clear();
m_posts.clear();
memset( &m_write_time, 0, sizeof( struct timeval ) );
m_write_time_date = std::string();

Expand Down Expand Up @@ -1017,11 +1017,11 @@ JDLIB::ConstPtr< NodeTreeBase >& ArticleBase::get_nodetree()
assert( m_nodetree );

// あぼーん情報のコピー
m_nodetree->copy_abone_info( m_list_abone_id, m_list_abone_name, m_list_abone_word, m_list_abone_regex, m_vec_abone_res,
m_nodetree->copy_abone_info( m_list_abone_id, m_list_abone_name, m_list_abone_word, m_list_abone_regex, m_abone_reses,
m_abone_transparent, m_abone_chain, m_abone_age, m_abone_board, m_abone_global );

// 書き込み情報のコピー
m_nodetree->copy_post_info( m_vec_posted );
m_nodetree->copy_post_info( m_posts );

m_nodetree->sig_updated().connect( sigc::mem_fun( *this, &ArticleBase::slot_node_updated ) );
m_nodetree->sig_finished().connect( sigc::mem_fun( *this, &ArticleBase::slot_load_finished ) );
Expand Down Expand Up @@ -1367,21 +1367,21 @@ void ArticleBase::slot_load_finished()
else m_number_new = 0;

// 書き込み情報
const auto& node_posted = m_nodetree->get_vec_posted();
if( m_number_new && node_posted.size() ){
const auto& node_posts = m_nodetree->get_posts();
if( m_number_new && node_posts.size() ) {

const auto end = m_vec_posted.end();
const auto node_end = node_posted.end();
const auto end = m_posts.end();
const auto node_end = node_posts.end();
for( int i = m_number_before_load +1; i <= m_number_load; ++i ){

if( node_posted.find( i ) != node_end ) {
m_vec_posted.insert( i );
if( node_posts.find( i ) != node_end ) {
m_posts.insert( i );
}
else {
m_vec_posted.erase( i );
m_posts.erase( i );
}
#ifdef _DEBUG
if( m_vec_posted.find( i ) != end ) std::cout << "posted no = " << i << std::endl;
if( m_posts.find( i ) != end ) std::cout << "posted no = " << i << std::endl;
#endif
}
}
Expand Down Expand Up @@ -1708,13 +1708,13 @@ void ArticleBase::delete_cache( const bool cache_only )
m_write_fixname = false;
m_write_fixmail = false;

m_vec_bookmark.clear();
m_vec_posted.clear();
m_bookmarks.clear();
m_posts.clear();
m_list_abone_id.clear();
m_list_abone_name.clear();
m_list_abone_word.clear();
m_list_abone_regex.clear();
m_vec_abone_res.clear();
m_abone_reses.clear();
m_abone_transparent = false;
m_abone_chain = false;
m_abone_age = false;
Expand Down Expand Up @@ -1888,12 +1888,12 @@ void ArticleBase::read_info()
if( ! str_tmp.empty() ){

list_tmp = MISC::split_line( str_tmp );
if( m_vec_bookmark.bucket_count() < list_tmp.size() ) {
m_vec_bookmark.reserve( list_tmp.size() + kExpectedResInfo );
if( m_bookmarks.bucket_count() < list_tmp.size() ) {
m_bookmarks.reserve( list_tmp.size() + kExpectedResInfo );
}
for( const std::string& num_str : list_tmp ) {
if( !num_str.empty() ) {
m_vec_bookmark.insert( std::stoi( num_str ) );
m_bookmarks.insert( std::stoi( num_str ) );
}
}
}
Expand All @@ -1917,17 +1917,17 @@ void ArticleBase::read_info()
if( ! str_tmp.empty() ) m_abone_chain = atoi( str_tmp.c_str() );

// レス番号あぼーん
m_vec_abone_res.clear();
m_abone_reses.clear();
GET_INFOVALUE( str_tmp, "aboneres = " );
if( ! str_tmp.empty() ){

list_tmp = MISC::split_line( str_tmp );
if( m_vec_abone_res.bucket_count() < list_tmp.size() ) {
m_vec_abone_res.reserve( list_tmp.size() + kExpectedResInfo );
if( m_abone_reses.bucket_count() < list_tmp.size() ) {
m_abone_reses.reserve( list_tmp.size() + kExpectedResInfo );
}
for( const std::string& num_str : list_tmp ) {
if( !num_str.empty() ) {
m_vec_abone_res.insert( std::stoi( num_str ) );
m_abone_reses.insert( std::stoi( num_str ) );
}
}
}
Expand All @@ -1942,12 +1942,12 @@ void ArticleBase::read_info()
if( ! str_tmp.empty() ){

list_tmp = MISC::split_line( str_tmp );
if( m_vec_posted.bucket_count() < list_tmp.size() ) {
m_vec_posted.reserve( list_tmp.size() + kExpectedResInfo );
if( m_posts.bucket_count() < list_tmp.size() ) {
m_posts.reserve( list_tmp.size() + kExpectedResInfo );
}
for( const std::string& num_str : list_tmp ) {
if( !num_str.empty() ) {
m_vec_posted.insert( std::stoi( num_str ) );
m_posts.insert( std::stoi( num_str ) );
}
}
}
Expand Down Expand Up @@ -2049,28 +2049,28 @@ void ArticleBase::read_info()
std::cout << "abone-regex\n"; it = m_list_abone_regex.begin();
for( ; it != m_list_abone_regex.end(); ++it ) std::cout << (*it) << std::endl;

if( !m_vec_abone_res.empty() ) {
if( !m_abone_reses.empty() ) {
std::cout << "abone-res =";
const auto end = m_vec_abone_res.end();
const auto end = m_abone_reses.end();
for( int i = 1; i <= m_number_load; ++i ) {
if( m_vec_abone_res.find( i ) != end ) std::cout << ' ' << i;
if( m_abone_reses.find( i ) != end ) std::cout << ' ' << i;
}
}

if( !m_vec_bookmark.empty() ) {
if( !m_bookmarks.empty() ) {
std::cout << "bookmark = ";
const auto end = m_vec_bookmark.end();
const auto end = m_bookmarks.end();
for( int i = 1; i <= m_number_load; ++i ) {
if( m_vec_bookmark.find( i ) != end ) std::cout << ' ' << i;
if( m_bookmarks.find( i ) != end ) std::cout << ' ' << i;
}
std::cout << std::endl;
}

if( !m_vec_posted.empty() ) {
if( !m_posts.empty() ) {
std::cout << "posted =";
const auto end = m_vec_posted.end();
const auto end = m_posts.end();
for( int i = 1; i <= m_number_load; ++i ) {
if( m_vec_posted.find( i ) != end ) std::cout << ' ' << i;
if( m_posts.find( i ) != end ) std::cout << ' ' << i;
}
std::cout << std::endl;
}
Expand Down Expand Up @@ -2124,28 +2124,28 @@ void ArticleBase::save_info( const bool force )

// レスあぼーん
std::ostringstream ss_abone_res;
if( !m_vec_abone_res.empty() ) {
const auto end = m_vec_abone_res.end();
if( !m_abone_reses.empty() ) {
const auto end = m_abone_reses.end();
for( int i = 1; i <= m_number_load; ++i ) {
if( m_vec_abone_res.find( i ) != end ) ss_abone_res << ' ' << i;
if( m_abone_reses.find( i ) != end ) ss_abone_res << ' ' << i;
}
}

// レスのブックマーク
std::ostringstream ss_bookmark;
if( !m_vec_bookmark.empty() ) {
const auto end = m_vec_bookmark.end();
if( !m_bookmarks.empty() ) {
const auto end = m_bookmarks.end();
for( int i = 1; i <= m_number_load; ++i ) {
if( m_vec_bookmark.find( i ) != end ) ss_bookmark << ' ' << i;
if( m_bookmarks.find( i ) != end ) ss_bookmark << ' ' << i;
}
}

// 書き込み
std::ostringstream ss_posted;
if( !m_vec_posted.empty() ) {
const auto end = m_vec_posted.end();
if( !m_posts.empty() ) {
const auto end = m_posts.end();
for( int i = 1; i <= m_number_load; ++i ) {
if( m_vec_posted.find( i ) != end ) ss_posted << ' ' << i;
if( m_posts.find( i ) != end ) ss_posted << ' ' << i;
}
}

Expand Down

0 comments on commit 5c4dd31

Please sign in to comment.