<commit_before>/*
 * LayoutAppender.cpp
 *
 * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
 * Copyright 2000, <NAME>. All rights reserved.
 *
 * See the COPYING file for the terms of usage and distribution.
 */

#include "log4cpp/Config.hh"
#include "log4cpp/OstringStream.hh"
#include "log4cpp/LayoutAppender.hh"
#include "log4cpp/SimpleLayout.hh"

namespace log4cpp {

    LayoutAppender::LayoutAppender(const std::string& name) : 
            AppenderSkeleton(name),
            _layout(new SimpleLayout()) {
    }
    
    LayoutAppender::~LayoutAppender() {
        delete _layout;
    }

    bool LayoutAppender::requiresLayout() const {
        return true;
    }

    void LayoutAppender::setLayout(Layout* layout) {
        Layout *oldLayout = _layout;
        _layout = (layout == NULL) ? new SimpleLayout() : layout;
        delete oldLayout;
    }

    Layout& LayoutAppender::_getLayout() {
        return *_layout;
    }
}
<commit_msg>use DefaultLayoutType to construct new Layouts. check whether old Layout and new Layout are the same object.<commit_after>/*
 * LayoutAppender.cpp
 *
 * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
 * Copyright 2000, <NAME>. All rights reserved.
 *
 * See the COPYING file for the terms of usage and distribution.
 */

#include "log4cpp/Config.hh"
#include "log4cpp/OstringStream.hh"
#include "log4cpp/LayoutAppender.hh"

namespace log4cpp {

    LayoutAppender::LayoutAppender(const std::string& name) : 
            AppenderSkeleton(name),
            _layout(new DefaultLayoutType()) {
    }
    
    LayoutAppender::~LayoutAppender() {
        delete _layout;
    }

    bool LayoutAppender::requiresLayout() const {
        return true;
    }

    void LayoutAppender::setLayout(Layout* layout) {
       if (layout != _layout) {
	  Layout *oldLayout = _layout;
	  _layout = (layout == NULL) ? new DefaultLayoutType() : layout;
	  delete oldLayout;
       }
    }

    Layout& LayoutAppender::_getLayout() {
        return *_layout;
    }
}

{'fraction_non_alphanumeric': 0.10932944606413994, 'fraction_numerical': 0.012147716229348883, 'mean_word_length': 3.0531496062992125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5358814', 'n_tokens_mistral': 640, 'n_tokens_neox': 604, 'n_words': 157}