<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef OGL_TEXTURECACHE_HXX
#define OGL_TEXTURECACHE_HXX

#include <sal/types.h>
#include <unordered_map>

namespace com { namespace sun { namespace star {
    namespace geometry { struct IntegerSize2D; }
}}}

namespace oglcanvas
{
    class TextureCache
    {
    public:
        TextureCache();
        ~TextureCache();

        /// clear whole cache, reset statistic counters
        void flush();

        /** prune old entries from cache

            Everytime this method is called, all cache entries are set
            to "old". If subsequently not used by getTexture(),
            they'll be entitled for expunge on the next prune()
            call. Resets statistic counters.
         */
        void prune();

        /// Statistics
        size_t getCacheSize() const { return maCache.size(); };
        sal_uInt32 getCacheMissCount() const { return mnMissCount; }
        sal_uInt32 getCacheHitCount() const { return mnHitCount; }

        unsigned int getTexture( const ::com::sun::star::geometry::IntegerSize2D& rPixelSize,
                                 const sal_Int8*                                  pPixel,
                                 sal_uInt32                                       nPixelCrc32) const;
    private:
        struct CacheEntry
        {
            CacheEntry() : nTexture(0), bOld(false) {}
            unsigned int nTexture;
            bool bOld;
        };
        typedef std::unordered_map<sal_uInt32,CacheEntry> TextureCacheMapT;
        mutable TextureCacheMapT maCache;
        mutable sal_uInt32       mnMissCount;
        mutable sal_uInt32       mnHitCount;
    };
}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<commit_msg>We're still stuck with boost::unordered_map<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef OGL_TEXTURECACHE_HXX
#define OGL_TEXTURECACHE_HXX

#include <sal/types.h>
#include <boost/unordered_map.hpp>

namespace com { namespace sun { namespace star {
    namespace geometry { struct IntegerSize2D; }
}}}

namespace oglcanvas
{
    class TextureCache
    {
    public:
        TextureCache();
        ~TextureCache();

        /// clear whole cache, reset statistic counters
        void flush();

        /** prune old entries from cache

            Everytime this method is called, all cache entries are set
            to "old". If subsequently not used by getTexture(),
            they'll be entitled for expunge on the next prune()
            call. Resets statistic counters.
         */
        void prune();

        /// Statistics
        size_t getCacheSize() const { return maCache.size(); };
        sal_uInt32 getCacheMissCount() const { return mnMissCount; }
        sal_uInt32 getCacheHitCount() const { return mnHitCount; }

        unsigned int getTexture( const ::com::sun::star::geometry::IntegerSize2D& rPixelSize,
                                 const sal_Int8*                                  pPixel,
                                 sal_uInt32                                       nPixelCrc32) const;
    private:
        struct CacheEntry
        {
            CacheEntry() : nTexture(0), bOld(false) {}
            unsigned int nTexture;
            bool bOld;
        };
        typedef boost::unordered_map<sal_uInt32,CacheEntry> TextureCacheMapT;
        mutable TextureCacheMapT maCache;
        mutable sal_uInt32       mnMissCount;
        mutable sal_uInt32       mnHitCount;
    };
}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

{'fraction_non_alphanumeric': 0.08935452793834296, 'fraction_numerical': 0.012524084778420038, 'mean_word_length': 2.0291757840991975, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3857468', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1136, 'n_words': 360}