~haggai-eran/unity-2d/rtl-rebased

« back to all changes in this revision

Viewing changes to libunity-2d-private/src/trash.cpp

  • Committer: Tarmac
  • Author(s): Albert Astals
  • Date: 2011-11-24 15:34:03 UTC
  • mfrom: (789.1.1 foreachconstref)
  • Revision ID: tarmac-20111124153403-p037jibq133f9ip4
[code] Add const & for foreach "iterators"

Avoids a copy of each object. It is true that most of those objects are
implicitly shared so the win isn't huge but we still save some atomic/mutex/something locking

Show diffs side-by-side

added added

removed removed

Lines of Context:
227
227
void
228
228
Trash::onDragEnter(DeclarativeDragDropEvent* event)
229
229
{
230
 
    Q_FOREACH(QUrl url, event->mimeData()->urls()) {
 
230
    Q_FOREACH(const QUrl& url, event->mimeData()->urls()) {
231
231
        if (url.scheme() == "file") {
232
232
            event->setDropAction(Qt::MoveAction);
233
233
            event->setAccepted(true);
239
239
void
240
240
Trash::onDrop(DeclarativeDragDropEvent* event)
241
241
{
242
 
    Q_FOREACH(QUrl url, event->mimeData()->urls()) {
 
242
    Q_FOREACH(const QUrl& url, event->mimeData()->urls()) {
243
243
        if (url.scheme() == "file") {
244
244
            GFile* file = g_file_new_for_path(url.toLocalFile().toUtf8().constData());
245
245
            if (!g_file_trash(file, NULL, NULL)) {